[FFmpeg-devel] [PATCH] ffplay: port avfilter buffersrc fps code from ffmpeg
Michael Niedermayer
michaelni at gmx.at
Wed Mar 27 21:54:41 CET 2013
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;
+ }
if (!buffersink_params)
return AVERROR(ENOMEM);
@@ -1773,6 +1783,8 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
frame->width, frame->height, frame->format,
is->video_st->time_base.num, is->video_st->time_base.den,
codec->sample_aspect_ratio.num, FFMAX(codec->sample_aspect_ratio.den, 1));
+ if (fr.num && fr.den)
+ av_strlcatf(buffersrc_args, sizeof(buffersrc_args), ":frame_rate=%d/%d", fr.num, fr.den);
if ((ret = avfilter_graph_create_filter(&filt_src,
avfilter_get_by_name("buffer"),
--
1.7.9.5
More information about the ffmpeg-devel
mailing list