aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-01-16 20:15:15 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-01-16 20:33:08 +0100
commitd3d9a00bcdfd5fc81d4640489555a3a41c82b303 (patch)
tree083893bcfc96990ff248c8a30b28f4ab11d6f08d /ffmpeg.c
parent7b32856011d1859a974b884f76bd17b7a7fdab76 (diff)
downloadffmpeg-d3d9a00bcdfd5fc81d4640489555a3a41c82b303.tar.gz
ffmpeg: Use filter graph output frame rate also for frame duration estimation
Previously the duration was sometimes wrong, this addition limits the value and improves which frames are choosen when reducing the frame rate Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 909dd68600..0a392747cd 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -895,6 +895,7 @@ static void do_video_out(AVFormatContext *s,
double duration = 0;
int frame_size = 0;
InputStream *ist = NULL;
+ AVFilterContext *filter = ost->filter->filter;
if (ost->source_index >= 0)
ist = input_streams[ost->source_index];
@@ -902,6 +903,13 @@ static void do_video_out(AVFormatContext *s,
if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
duration = 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base));
+ // We take the conservative approuch here and take the minimum even though
+ // this should be correct on its own but a value too small is harmless, one
+ // too big can lead to errors
+ if (filter->inputs[0]->frame_rate.num > 0 &&
+ filter->inputs[0]->frame_rate.den > 0)
+ duration = FFMIN(duration, 1/(av_q2d(filter->inputs[0]->frame_rate) * av_q2d(enc->time_base)));
+
if (!ost->filters_script &&
!ost->filters &&
next_picture &&