[FFmpeg-devel] [PATCH] VFW capture support

Ramiro Polla ramiro
Wed Mar 5 19:42:58 CET 2008


Hello Michael,

Michael Niedermayer wrote:
> On Mon, Mar 03, 2008 at 01:59:03PM -0300, Ramiro Polla wrote:
> [...]
>> static LRESULT CALLBACK FrameCallbackProc( HWND hwnd, LPVIDEOHDR vdhdr )
>> {
>>     struct vfw_ctx *ctx;
>>     AVPacket *pkt;
>>
>>     ctx = (struct vfw_ctx *) SendMessage( hwnd, WM_CAP_GET_USER_DATA, 0, 0 );
>>     if( !ctx )
>>         return FALSE;
>>
>>     pkt = ctx->pkt;
>>
>>     if( av_new_packet( pkt, vdhdr->dwBytesUsed ) < 0 )
>>         return FALSE;
>>
>>     pkt->pts = GetTickCount( );
> 
> Doesnt vfw provide some timestamp for each frame?

The timestamps returned are incredibly unreliable (if returned at all, 
most times I just get 0x00000000).

> [...]
>>     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?

> [...]
>> static int vfw_read_packet( AVFormatContext *s, AVPacket *pkt )
>> {
>>     struct vfw_ctx *ctx = s->priv_data;
>>     int ret;
>>
>>     ctx->pkt = pkt;
>>     ctx->grabbed = 0;
>>
>>     ret = SendMessage( ctx->hwnd, WM_CAP_GRAB_FRAME, 0, 0 );
>>     if( !ret || !ctx->grabbed )
>>         return AVERROR_IO;
>>
> 
> Hmm, cant the grabbing of the next frame be activated before returning?
> If no, then i think this has to be run in a seprate thread to work
> reliable.

IMHO, I think every indev should only start capturing when read_packet 
is called. So that, for example, I could have an app that only calls 
read_packet on an indev when some external event occurs, and it won't 
end up with last minute's image.

Ramiro Polla




More information about the ffmpeg-devel mailing list