[FFmpeg-devel] [PATCH] VFW capture support

Ramiro Polla ramiro
Fri Mar 7 18:52:18 CET 2008

Hello Michael,

I've rewritten vfwcap to use a different capture strategy. It's more 
complex but much more accurate now.

>>> Doesnt vfw provide some timestamp for each frame?
>> The timestamps returned are incredibly unreliable (if returned at all, 
>> most times I just get 0x00000000).
> Could you give me a hint of how they are returned, so i can check the docs
> from M$ ?
> Use of "get current time" is very problematic as frames will have very
> inaccuarte timestamps.
> Thus if that is the only kind of time you can get from VFW then i fear
> you will need to clean them up somehow so that they are at least stable
> to +- 1ms of the nominal frame rate of the video source.

Using the grab_frame strategy no timestamps were returned. With this new 
implementation the timestamps returned are accurate. There's no more 
need to use the system time.


>>>>     if( s->flags & AVFMT_FLAG_NONBLOCK ) {
>>>>         av_log( s, AV_LOG_ERROR, "Non blocking capture not yet implemented.\n" );
>>>>         return AVERROR_PATCHWELCOME;
>>>>     }
>>> where is the problem with that?
>> I thought we didn't want FFmpeg to block unless the user specifies 
>> AVFMT_FLAG_NONBLOCK. Isn't that the purpose of the flag?
> Yes, what i was asking, is where the problem is with implementing support

The new implementation deals better with AVFMT_FLAG_NONBLOCK. It does 
pretty much the same thing v4l2 does.


> Also can this patch do full framerate(30/25fps 50/60fields/sec) / full
> resolution realtime capture and encoding in realtime with audio? If not
> its definitly not well implemented.
> Also does VFW buffer frames? If no then a seperate thread is pretty much
> required for video capture. OTOH if it does buffer frames then the way
> you generate timestamps is just wrong.

VFW does buffer frames. The timestamps were indeed very inaccurate using 
the system time.

Mans suggested using a ring buffer, a semaphore and dropping frames 
instead of using the mutexes and events and piling up every single frame.

If it is preferred to drop frames, is there an existing option that 
could be used to set the maximum amount of memory/time buffered?

Ramiro Polla

P.S.: Most capture interfaces are horribly implemented. There are lots 
of static variables around and system times being passed as pts.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vfwcap.c
Type: text/x-csrc
Size: 11342 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080307/650848da/attachment.c>

More information about the ffmpeg-devel mailing list