[FFmpeg-devel] ffplay: Incorrect frame_delay?

Marton Balint cus at passwd.hu
Sun May 27 17:05:01 CEST 2012

On Sun, 27 May 2012, Robert Nagy wrote:
> I believe the "frame_delay" calculation in queue_picture is incorrect,
> though I am not sure how one would fix it.

Frame delay is only used for guessing the pts of the next frame if the
pts is not set, usually it is not used at all. In fact, I don't know if
there is any file where this guessing is used.

Don't worry about VideoPicture->duration, it is completely unused in the 
current code, I already have a patch which removes it, I will post it 

>> static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_t pos)
>> {
>>     VideoPicture *vp;
>>     double frame_delay, pts = pts1;
>>     /* compute the exact PTS for the picture if it is omitted in the stream
>>      * pts1 is the dts of the pkt / pts of the frame */
>>     if (pts != 0) {
>>         /* update video clock with pts, if present */
>>         is->video_clock = pts;
>>     } else {
>>         pts = is->video_clock;
>>     }
>>     /* update video clock for next frame */
>>     frame_delay = av_q2d(is->video_st->codec->time_base);
>>     /* for MPEG2, the frame can be repeated, so we update the
>>        clock accordingly */
>>     frame_delay += src_frame->repeat_pict * (frame_delay * 0.5);
>>     is->video_clock += frame_delay;
> First of all instead of av_q2d(is->video_st->codec->time_base) I think
> av_q2d(is->video_out_filter->inputs[0]->time_base) should be used.

That may be true, but I wonder if anybody can find a file and a filter 
where it really makes a difference.

> Secondly this code seems to assume that the pts delta is always 1
> (i.e. next_pts - cur_pext == 1), which isn't always the case. One way
> to solve it I guess would be to poll the next frame as well and use
> the delta, however that assumes that the pts is correct and
> continuous.

If we know the pts of the next frame, we don't need the guessed pts at 
all, so there is no reason to do that.

> Not sure what the best approach is?

Fixing the time base can be done, but I don't think it is too important, 
because it is only a guessed duration of the frame, which you usually 
don't use.


More information about the ffmpeg-devel mailing list