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

Revision 9854, 1.7 kB (checked in by robert, 5 years ago)

Added support for using libswscale

RevLine 
[9816]1
2#include <osgDB/Registry>
3#include <osgDB/FileNameUtils>
4#include <osgDB/FileUtils>
5
6#include "FFmpegHeaders.hpp"
7#include "FFmpegImageStream.hpp"
8
9
10
11/** Implementation heavily inspired by http://www.dranger.com/ffmpeg/ */
12
13class ReaderWriterFFmpeg : public osgDB::ReaderWriter
14{
15public:
16
17    ReaderWriterFFmpeg()
18    {
19        supportsExtension("avi", "");
20        supportsExtension("flv", "");
21        supportsExtension("mov", "");
[9838]22        supportsExtension("ogg", "Theora movie format");
[9816]23        supportsExtension("mpg", "Mpeg movie format");
24        supportsExtension("mpv", "Mpeg movie format");
25        supportsExtension("wmv", "");
26
27        // Register all FFmpeg formats/codecs
28        av_register_all();
29    }
30
31    virtual ~ReaderWriterFFmpeg()
32    {
33
34    }
35
36    virtual const char * className() const
37    {
38        return "ReaderWriterFFmpeg";
39    }
40
41    virtual ReadResult readImage(const std::string & filename, const osgDB::ReaderWriter::Options * options) const
42    {
43        const std::string ext = osgDB::getLowerCaseFileExtension(filename);
44
45        if (! acceptsExtension(ext))
46            return ReadResult::FILE_NOT_HANDLED;
47
[9854]48        const std::string path = osgDB::containsServerAddress(filename) ?
49            filename :
50            osgDB::findDataFile(filename, options);
[9816]51
52        if (path.empty())
53            return ReadResult::FILE_NOT_FOUND;
54
55        osg::notify(osg::INFO) << "ReaderWriterFFmpeg::readImage " << path << std::endl;
56
57        osg::ref_ptr<osgFFmpeg::FFmpegImageStream> image_stream(new osgFFmpeg::FFmpegImageStream);
58
59        if (! image_stream->open(path))
60            return ReadResult::FILE_NOT_HANDLED;
61
62        return image_stream.release();
63    }
64
65private:
66
67};
68
69
70
71REGISTER_OSGPLUGIN(ffmpeg, ReaderWriterFFmpeg)
Note: See TracBrowser for help on using the browser.