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>
... | ... |
@@ -895,6 +895,7 @@ static void do_video_out(AVFormatContext *s, |
895 | 895 |
double duration = 0; |
896 | 896 |
int frame_size = 0; |
897 | 897 |
InputStream *ist = NULL; |
898 |
+ AVFilterContext *filter = ost->filter->filter; |
|
898 | 899 |
|
899 | 900 |
if (ost->source_index >= 0) |
900 | 901 |
ist = input_streams[ost->source_index]; |
... | ... |
@@ -902,6 +903,13 @@ static void do_video_out(AVFormatContext *s, |
902 | 902 |
if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num) |
903 | 903 |
duration = 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base)); |
904 | 904 |
|
905 |
+ // We take the conservative approuch here and take the minimum even though |
|
906 |
+ // this should be correct on its own but a value too small is harmless, one |
|
907 |
+ // too big can lead to errors |
|
908 |
+ if (filter->inputs[0]->frame_rate.num > 0 && |
|
909 |
+ filter->inputs[0]->frame_rate.den > 0) |
|
910 |
+ duration = FFMIN(duration, 1/(av_q2d(filter->inputs[0]->frame_rate) * av_q2d(enc->time_base))); |
|
911 |
+ |
|
905 | 912 |
if (!ost->filters_script && |
906 | 913 |
!ost->filters && |
907 | 914 |
next_picture && |