From Cedric Pinson, "Here an update of the directshow plugin. It fixes issues with
synchronization, improve capture device support.
here how to use it to display a capture device:
osg::Options* options = new osg::Options;
options->setPluginStringData("captureWantedWidth", "800");
options->setPluginStringData("captureWantedHeight", "600");
options->setPluginStringData("captureWantedFps", "30");
options->setPluginStringData("captureVideoDevice", "USB Video Device" );
options->setPluginStringData("captureSoundDevice", "");
then
osgDB::readImageFile("capture.directshow", options)
you can use a graphedit application to list devices available in
directshow.
for classic avi file you just need to do a
osgDB::readImageFile("file.avi.directshow");
You will need of course to install the codec needed by directshow to
read the avi files.
I recommand this tool http://avicodec.duby.info/, that check which
video/sound codec is needed to play an avi file.
You can test it with the osgmovie example.
"
This commit is contained in:
94
src/osgPlugins/directshow/ReaderWriterDirectShow.cpp
Normal file
94
src/osgPlugins/directshow/ReaderWriterDirectShow.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 2009 Tharsis Software
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Cedric Pinson <cedric.pinson@plopbyte.net>
|
||||
*/
|
||||
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
#include "DirectShowTexture"
|
||||
|
||||
|
||||
class ReaderWriterDirectShow : public osgDB::ReaderWriter
|
||||
{
|
||||
public:
|
||||
|
||||
ReaderWriterDirectShow()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~ReaderWriterDirectShow()
|
||||
{
|
||||
}
|
||||
|
||||
virtual const char * className() const
|
||||
{
|
||||
return "ReaderWriterDirectShow";
|
||||
}
|
||||
|
||||
virtual ReadResult readImage(const std::string & filename, const osgDB::ReaderWriter::Options * options) const
|
||||
{
|
||||
const std::string ext = osgDB::getLowerCaseFileExtension(filename);
|
||||
if (ext=="directshow") return readImage(osgDB::getNameLessExtension(filename),options);
|
||||
return readImageStream(filename, options);
|
||||
}
|
||||
|
||||
ReadResult readImageStream(const std::string& filename, const osgDB::ReaderWriter::Options * options) const
|
||||
{
|
||||
osg::notify(osg::INFO) << "ReaderWriterFFmpeg::readImage " << filename << std::endl;
|
||||
const std::string path = osgDB::containsServerAddress(filename) ?
|
||||
filename :
|
||||
osgDB::findDataFile(filename, options);
|
||||
|
||||
osg::ref_ptr<DirectShowImageStream> image_stream(new DirectShowImageStream);
|
||||
|
||||
if (path.empty()) // try with capture
|
||||
{
|
||||
std::map<std::string,std::string> map;
|
||||
if (options)
|
||||
{
|
||||
map["captureWantedWidth"] = options->getPluginStringData("captureWantedWidth");
|
||||
map["captureWantedHeight"] = options->getPluginStringData("captureWantedHeight");
|
||||
map["captureWantedFps"] = options->getPluginStringData("captureWantedFps");
|
||||
map["captureVideoDevice"] = options->getPluginStringData("captureVideoDevice");
|
||||
map["captureSoundDevice"] = options->getPluginStringData("captureSoundDevice");
|
||||
map["captureSoundDeviceNbChannels"] = options->getPluginStringData("captureSoundDeviceNbChannels");
|
||||
}
|
||||
if (filename != "capture")
|
||||
{
|
||||
if (!options || (options && options->getPluginStringData("captureVideoDevice").empty()))
|
||||
map["captureVideoDevice"] = filename;
|
||||
}
|
||||
image_stream->setOptions(map);
|
||||
|
||||
if (! image_stream->openCaptureDevices())
|
||||
return ReadResult::FILE_NOT_HANDLED;
|
||||
return image_stream.release();
|
||||
}
|
||||
|
||||
if (! image_stream->openFile(filename))
|
||||
return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
return image_stream.release();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
REGISTER_OSGPLUGIN(directshow, ReaderWriterDirectShow)
|
||||
Reference in New Issue
Block a user