[FFmpeg-devel] ffplay: Incorrect frame_delay?

Robert Nagy ronag89 at gmail.com
Sun May 27 13:48:58 CEST 2012


I believe the "frame_delay" calculation in queue_picture is incorrect,
though I am not sure how one would fix 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.

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.

Not sure what the best approach is?


More information about the ffmpeg-devel mailing list