From Wang Rui, "additional FFmpegParameters class in the ffmpeg plugin for setting parameters before opening the video file, which benefits from getPluginStringData() as shown in the ReaderWriter implementation.

Now we can use ffmpeg to render webcam video (using the vfwcap device) under Windows:

osgmovie 0 -e ffmpeg -O "format=vfwcap frame_rate=25"

The number 0 just indicates a default device number in ffmpeg.

I think this can work under Linux, too, and should be a bit better than comparing the filename with a '/dev/' string. Just type:

./osgmovie /dev/yourcam -e ffmpeg -O "format=video4linux2 frame_rate=30 size=320x240""
This commit is contained in:
Robert Osfield
2010-11-03 10:37:32 +00:00
parent afa563df57
commit 4ced7dffc4
8 changed files with 168 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
#include "FFmpegDecoder.hpp"
#include "FFmpegParameters.hpp"
#include <osg/Notify>
#include <osgDB/FileNameUtils>
@@ -36,7 +37,7 @@ FFmpegDecoder::~FFmpegDecoder()
}
bool FFmpegDecoder::open(const std::string & filename)
bool FFmpegDecoder::open(const std::string & filename, FFmpegParameters* parameters)
{
try
{
@@ -100,7 +101,9 @@ bool FFmpegDecoder::open(const std::string & filename)
}
else
{
if (av_open_input_file(&p_format_context, filename.c_str(), 0, 0, 0) !=0 )
AVInputFormat* av_format = (parameters ? parameters->getFormat() : 0);
AVFormatParameters* av_params = (parameters ? parameters->getFormatParameter() : 0);
if (av_open_input_file(&p_format_context, filename.c_str(), av_format, 0, av_params) !=0 )
throw std::runtime_error("av_open_input_file() failed");
}