[FFmpeg-devel] [PATCH] Frame rate emulation

Ramiro Ribeiro Polla ramiro
Thu Jun 21 01:36:06 CEST 2007


Michael Niedermayer wrote:
> Hi
>
> On Sun, Jun 17, 2007 at 06:59:30PM -0300, Ramiro Ribeiro Polla wrote:
> [...]
>   
>>> [...]
>>>  
>>>       
>>>> Index: libavformat/utils.c
>>>> ===================================================================
>>>> --- libavformat/utils.c	(revision 9347)
>>>> +++ libavformat/utils.c	(working copy)
>>>> @@ -2900,3 +2900,21 @@
>>>>     }
>>>>     f->num = num;
>>>> }
>>>> +
>>>> +int av_rate_emu(AVRateEmu *rate_emu)
>>>> +{
>>>> +    int64_t pts = av_rescale((int64_t) rate_emu->frame * 
>>>> rate_emu->time_base.num, 1000000, rate_emu->time_base.den);
>>>> +    int64_t now = av_gettime() - rate_emu->start;
>>>> +    if (pts > now)
>>>> +        return AVERROR(EAGAIN);
>>>>    
>>>>         
>>> i think it should return the number of (micro/milli/nano whatever) seconds
>>> left
>>>
>>>  
>>>       
>> Done.
>>
>> Patch attached.
>>
>> Ramiro Polla
>>     
>
>   
>> Index: ffmpeg.c
>> ===================================================================
>> --- ffmpeg.c	(revision 9356)
>> +++ ffmpeg.c	(working copy)
>> @@ -1878,7 +1878,9 @@
>>  
>>          /* read a frame from it and output it in the fifo */
>>          is = input_files[file_index];
>> -        if (av_read_frame(is, &pkt) < 0) {
>> +        if ((ret = av_read_frame(is, &pkt)) < 0) {
>> +            if (ret == AVERROR(EAGAIN))
>> +                continue;
>>              file_table[file_index].eof_reached = 1;
>>              if (opt_shortest) break; else continue; //
>>          }
>>     
>
> ok but please commit this seperately
>
> [...]
>
>   
>> @@ -270,8 +263,8 @@
>>      st->codec->codec_id = CODEC_ID_RAWVIDEO;
>>      st->codec->width = width;
>>      st->codec->height = height;
>> -    st->codec->time_base.den      = frame_rate;
>> -    st->codec->time_base.num = frame_rate_base;
>> +    st->codec->time_base.den = ap->time_base.den;
>> +    st->codec->time_base.num = ap->time_base.num;
>>     
>
> st->codec->time_base= ap->time_base;
>
> except these and a missing minor version increase the patch looks ok
> asuming you did test the changes grabing demxuers (AV sync amongth others
> should not get worse)
>
>   

I won't apply this (at least for now) since the discussion seems to be 
pointing to be a better solution (or looking for a better solution).

There have been suggestions of libavgrab before (I'd prefer the name 
libavdevice though). Would this help in any way? Further thoughts on it? 
I'll go through the ml later to see exactly what was discussed.

Ramiro Polla




More information about the ffmpeg-devel mailing list