[FFmpeg-devel] [PATCH] ffplay: port avfilter buffersrc fps code from ffmpeg

Marton Balint cus at passwd.hu
Thu Mar 28 02:31:24 CET 2013



On Wed, 27 Mar 2013, Michael Niedermayer wrote:

> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
> ffplay.c |   12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/ffplay.c b/ffplay.c
> index fb09dd6..abf7419 100644
> --- a/ffplay.c
> +++ b/ffplay.c
> @@ -1760,6 +1760,16 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
>     AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc();
>     AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_crop;
>     AVCodecContext *codec = is->video_st->codec;
> +    AVRational fr = is->video_st->r_frame_rate;
> +
> +    if (is->video_st->codec->ticks_per_frame>1) {
> +        AVRational codec_fr = av_inv_q(is->video_st->codec->time_base);
> +        AVRational   avg_fr = is->video_st->avg_frame_rate;
> +        codec_fr.den *= is->video_st->codec->ticks_per_frame;
> +        if (   codec_fr.num>0 && codec_fr.den>0 && av_q2d(codec_fr) < av_q2d(fr)*0.7
> +            && fabs(1.0 - av_q2d(av_div_q(avg_fr, fr)))>0.1)
> +            fr = codec_fr;
> +    }

Shouldn't this code be part of the public API? E.g. 
AVRational av_guess_frame_rate(*AVStream, *AVCodec)?

Regards,
Marton


More information about the ffmpeg-devel mailing list