OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

ffmpeg plugin streaming video proof of concept

Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Plugins [osgPlugins]
View previous topic :: View next topic  
Author Message
Robert Osfield

PostPosted: Thu Mar 05, 2009 11:16 am    Post subject:
ffmpeg plugin streaming video proof of concept
Reply with quote

Hi All,

We now have the beginnings of the ffmpeg checked into svn/trunk, and
my hope is that this might one day get capable enough to replace the
existing xine-lib plugin and quicktime plugins as the source of video
support. Just having one video backend would help with maintenance as
well enabling a full feature set across all platforms, but this will
only be possible if we can get the new ffmpeg working well across all
platforms with all the original functionality. One item that the
quicktime plugin has is stream support under Windows and OSX, so...
this is also one of the items that needs to be added if possible.

The "if possible" question is something that I wanted to explore, and
various code fragments on the web suggested that it was possible, so
I've hacked together a proof of concept extension to the ffmpeg so
that it attempts to open a video device as input. This didn't
actually take too long to try out, so under linux you can now do:

osgmovie -e ffmpeg /dev/video0

Which if you have a webcam or similar device on /dev/video0 it'll open
it up using video4linux2 and stream it, full screen.

The proof of concept is only a dozen lines of code so far, with
defaults chosen that work fine for my hardware/OS setup. For other
OS's the settings will certainly be different, and it's not entirely
clear to me that ffmpeg does support such device streaming across all
platforms... More investigation will be required. Please dive in to
ffmpeg docs/online discussions to see if you can spot the approach to
take under Windows + OSX etc.

For a final incarnation of live video streaming support we'll need to
add controls for the various device parameters, either via parsing of
ReaderWriter::Options strings, or extended Options to include
appropriate device parameters. We will probably need some kind of
scheme for querying the device options available too. I really don't
have much of clue how we might go about all this yet as it's very
early days for me delving into this side of things.

For those interested in helping out with development of the streaming
support have a look at the code I just added to
src/osgPlugins/ffmpeg/FFmpegDecode.cpp, in particular the bool
FFmpegDecoder::open(const std::string & filename) method:

if (, 5, "/dev/")==0)

osg::notify(osg::NOTICE)<<"Attempting to stream

AVFormatParameters formatParams;
memset(&formatParams, 0, sizeof(AVFormatParameters));
AVInputFormat *iformat; = 0;
formatParams.standard = 0;
formatParams.width = 640;
formatParams.height = 480;
formatParams.time_base.num = 1;
formatParams.time_base.den = 50;

iformat = av_find_input_format("video4linux2");

if (iformat)
osg::notify(osg::NOTICE)<<"Found input format"<<std::endl;
osg::notify(osg::NOTICE)<<"Failed to find

if (av_open_input_file(&p_format_context,
filename.c_str(), iformat, 0, &formatParams) != 0)
throw std::runtime_error("av_open_input_file() failed");
if (av_open_input_file(&p_format_context,
filename.c_str(), 0, 0, 0) !=0 )
throw std::runtime_error("av_open_input_file() failed");

The ReaderWriter::readImage(..) method also catches the /dev/ filename
usage, so if you try this out for a non linux platform you'll need to
tweak the filename checking here as well.


Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Plugins [osgPlugins] All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Problems with dae plugin John Richardson Plugins [osgPlugins] 0 Thu Apr 11, 2019 5:00 pm View latest post
No new posts [PARTIALLY SOLVED] Problems with dae ... Nikkitta Plugins [osgPlugins] 4 Mon Apr 08, 2019 3:51 pm View latest post
No new posts Add search location for textures in F... bbjorn Submission 1 Mon Feb 04, 2019 2:22 pm View latest post
No new posts OSG GLTF loader plugin Chris Hanson General 0 Thu Dec 06, 2018 9:55 pm View latest post
No new posts playing videos with audio channels wi... Trajce Nikolov NICK General 7 Wed Nov 21, 2018 9:17 pm View latest post

Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP