root/OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/ReaderWriterFFmpeg.cpp @ 9965

Revision 9965, 2.8 kB (checked in by robert, 6 years ago)

From Ulrich Hertlein, "I got the following type error from gcc 4.0.1 on OS X 10.5.6:
/Users/uli/Projects/osg/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp: In member function \u2018int osgFFmpeg::FFmpegDecoderVideo::convert(AVPicture*, int, AVPicture*, int, int, int)\u2019:
/Users/uli/Projects/osg/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp:245: error: invalid conversion from \u2018int\u2019 to \u2018PixelFormat\u2019
/Users/uli/Projects/osg/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp:245: error: initializing argument 3 of \u2018SwsContext* sws_getContext(int, int, PixelFormat?, int, int, PixelFormat?, int, SwsFilter?*, SwsFilter?*, double*)\u2019

It expects 'src_pix_fmt' and 'dst_pix_fmt' to be of type 'PixelFormat?' rather than int. The attached cast fixes this (for me).

I've also added Matroska video to the list of supported extensions"

RevLine 
[9885]1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under 
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
[9816]13
14#include <osgDB/Registry>
15#include <osgDB/FileNameUtils>
16#include <osgDB/FileUtils>
17
18#include "FFmpegHeaders.hpp"
19#include "FFmpegImageStream.hpp"
20
21
22
23/** Implementation heavily inspired by http://www.dranger.com/ffmpeg/ */
24
25class ReaderWriterFFmpeg : public osgDB::ReaderWriter
26{
27public:
28
29    ReaderWriterFFmpeg()
30    {
[9885]31        supportsProtocol("http","Read video/audio from http using ffmpeg.");
32
[9816]33        supportsExtension("avi", "");
34        supportsExtension("flv", "");
35        supportsExtension("mov", "");
[9838]36        supportsExtension("ogg", "Theora movie format");
[9816]37        supportsExtension("mpg", "Mpeg movie format");
38        supportsExtension("mpv", "Mpeg movie format");
[9965]39        supportsExtension("wmv", "Windows Media Video format");
40        supportsExtension("mkv", "Matroska");
[9816]41
42        // Register all FFmpeg formats/codecs
43        av_register_all();
44    }
45
46    virtual ~ReaderWriterFFmpeg()
47    {
48
49    }
50
51    virtual const char * className() const
52    {
53        return "ReaderWriterFFmpeg";
54    }
55
56    virtual ReadResult readImage(const std::string & filename, const osgDB::ReaderWriter::Options * options) const
57    {
[9865]58        if (filename.compare(0, 5, "/dev/")==0)
59        {
60            return readImageStream(filename, options);
61        }
62   
[9816]63        const std::string ext = osgDB::getLowerCaseFileExtension(filename);
64        if (! acceptsExtension(ext))
65            return ReadResult::FILE_NOT_HANDLED;
66
[9854]67        const std::string path = osgDB::containsServerAddress(filename) ?
68            filename :
69            osgDB::findDataFile(filename, options);
[9816]70
71        if (path.empty())
72            return ReadResult::FILE_NOT_FOUND;
73
[9865]74        return readImageStream(filename, options);
75    }
76   
77    ReadResult readImageStream(const std::string& filename, const osgDB::ReaderWriter::Options * options) const
78    {
79        osg::notify(osg::INFO) << "ReaderWriterFFmpeg::readImage " << filename << std::endl;
[9816]80
81        osg::ref_ptr<osgFFmpeg::FFmpegImageStream> image_stream(new osgFFmpeg::FFmpegImageStream);
82
[9865]83        if (! image_stream->open(filename))
[9816]84            return ReadResult::FILE_NOT_HANDLED;
85
86        return image_stream.release();
87    }
88
89private:
90
91};
92
93
94
95REGISTER_OSGPLUGIN(ffmpeg, ReaderWriterFFmpeg)
Note: See TracBrowser for help on using the browser.