[FFmpeg-cvslog] fftools/ffmpeg_enc: always use video frame durations when available
Anton Khirnov
git at videolan.org
Mon Apr 24 18:02:51 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Apr 15 09:46:29 2023 +0200| [c94e9d03b44d21282418dfb6c84f4f7942d4db03] | committer: Anton Khirnov
fftools/ffmpeg_enc: always use video frame durations when available
Previously they would only be used with trivial filtergraphs, because
filters did not handle frame durations. That is no longer true - most
filters process frame durations properly (there may still be some that
don't - this change will help finding and fixing them).
Improves output video frame durations in a number of FATE tests.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c94e9d03b44d21282418dfb6c84f4f7942d4db03
---
fftools/ffmpeg_enc.c | 19 ++++------
tests/ref/fate/filter-concat-vfr | 66 +++++++++++++++++-----------------
tests/ref/fate/gif-disposal-restore | 2 +-
tests/ref/fate/gif-gray | 72 ++++++++++++++++++-------------------
tests/ref/fate/quickdraw | 2 +-
5 files changed, 77 insertions(+), 84 deletions(-)
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index e3dc858bc3..9aaec277f1 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -1005,24 +1005,17 @@ static void do_video_out(OutputFile *of,
AVRational frame_rate;
int64_t nb_frames, nb_frames_prev, i;
double duration = 0;
- InputStream *ist = ost->ist;
AVFilterContext *filter = ost->filter->filter;
- frame_rate = av_buffersink_get_frame_rate(filter);
- if (frame_rate.num > 0 && frame_rate.den > 0)
- duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base));
+ if (next_picture)
+ duration = lrintf(next_picture->duration * av_q2d(next_picture->time_base) / av_q2d(enc->time_base));
- if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
+ if (duration <= 0 && ost->frame_rate.num)
duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base)));
- if (!ost->filters_script &&
- !ost->filters &&
- (nb_filtergraphs == 0 || !filtergraphs[0]->graph_desc) &&
- next_picture &&
- ist &&
- lrintf(next_picture->duration * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) {
- duration = lrintf(next_picture->duration * av_q2d(ist->st->time_base) / av_q2d(enc->time_base));
- }
+ frame_rate = av_buffersink_get_frame_rate(filter);
+ if (duration <= 0 && frame_rate.num > 0 && frame_rate.den > 0)
+ duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base));
if (!next_picture) {
//end, flushing
diff --git a/tests/ref/fate/filter-concat-vfr b/tests/ref/fate/filter-concat-vfr
index 7c5e12e093..66e9007da8 100644
--- a/tests/ref/fate/filter-concat-vfr
+++ b/tests/ref/fate/filter-concat-vfr
@@ -8,7 +8,7 @@
#codec_id 1: pcm_s16le
#sample_rate 1: 44100
#channel_layout_name 1: mono
-0, 0, 0, 0, 230400, 0x88c4d19a
+0, 0, 0, 199999, 230400, 0x88c4d19a
1, 0, 0, 1024, 2048, 0xb3f10192
1, 1024, 1024, 1024, 2048, 0xb340fe4e
1, 2048, 2048, 1024, 2048, 0x0a5f0111
@@ -18,7 +18,7 @@
1, 6144, 6144, 1024, 2048, 0x70a8fa17
1, 7168, 7168, 1024, 2048, 0x0dad072a
1, 8192, 8192, 1024, 2048, 0x5e810c51
-0, 200000, 200000, 0, 230400, 0x0d77c977
+0, 200000, 200000, 200000, 230400, 0x0d77c977
1, 9216, 9216, 1024, 2048, 0xbe5bf462
1, 10240, 10240, 1024, 2048, 0xbcd9faeb
1, 11264, 11264, 1024, 2048, 0x0d5bfe9c
@@ -28,7 +28,7 @@
1, 15360, 15360, 1024, 2048, 0x11a9fa03
1, 16384, 16384, 1024, 2048, 0x9a920378
1, 17408, 17408, 1024, 2048, 0x901b0525
-0, 400000, 400000, 0, 230400, 0x242629d7
+0, 400000, 400000, 200000, 230400, 0x242629d7
1, 18432, 18432, 1024, 2048, 0x74b2003f
1, 19456, 19456, 1024, 2048, 0xa20ef3ed
1, 20480, 20480, 1024, 2048, 0x44cef9de
@@ -37,7 +37,7 @@
1, 23552, 23552, 1024, 2048, 0xcab6f9e5
1, 24576, 24576, 1024, 2048, 0x67f8f608
1, 25600, 25600, 1024, 2048, 0x8d7f03fa
-0, 600000, 600000, 0, 230400, 0x62cdc018
+0, 600000, 600000, 200000, 230400, 0x62cdc018
1, 26624, 26624, 1024, 2048, 0x3e1e0566
1, 27648, 27648, 1024, 2048, 0x2cfe0308
1, 28672, 28672, 1024, 2048, 0x1ceaf702
@@ -47,7 +47,7 @@
1, 32768, 32768, 1024, 2048, 0x3e5afa28
1, 33792, 33792, 1024, 2048, 0x053ff47a
1, 34816, 34816, 1024, 2048, 0x0d28fed9
-0, 800000, 800000, 0, 230400, 0x248ad058
+0, 800000, 800000, 200000, 230400, 0x248ad058
1, 35840, 35840, 1024, 2048, 0x279805cc
1, 36864, 36864, 1024, 2048, 0xb16a0a12
1, 37888, 37888, 1024, 2048, 0xb45af340
@@ -57,72 +57,72 @@
1, 41984, 41984, 1024, 2048, 0x503800ce
1, 43008, 43008, 1024, 2048, 0xa3bbf4af
1, 44032, 44032, 68, 136, 0xc8d751c7
-0, 1000000, 1000000, 0, 230400, 0x223d134f
+0, 1000000, 1000000, 200000, 230400, 0x223d134f
1, 44100, 44100, 9600, 19200, 0x00000000
-0, 1200000, 1200000, 0, 230400, 0xbf1c3d34
+0, 1200000, 1200000, 200000, 230400, 0xbf1c3d34
1, 53700, 53700, 9600, 19200, 0x00000000
-0, 1400000, 1400000, 0, 230400, 0xae0efe96
+0, 1400000, 1400000, 200000, 230400, 0xae0efe96
1, 63300, 63300, 9600, 19200, 0x00000000
-0, 1600000, 1600000, 0, 230400, 0x0cd624d1
+0, 1600000, 1600000, 200000, 230400, 0x0cd624d1
1, 72900, 72900, 9600, 19200, 0x00000000
-0, 1800000, 1800000, 0, 230400, 0x6dedf2c0
+0, 1800000, 1800000, 200000, 230400, 0x6dedf2c0
1, 82500, 82500, 5700, 11400, 0x00000000
-0, 2000000, 2000000, 0, 230400, 0x88c4d19a
+0, 2000000, 2000000, 66667, 230400, 0x88c4d19a
1, 88200, 88200, 1024, 2048, 0x283efb3a
1, 89224, 89224, 1024, 2048, 0x7692fb8f
1, 90248, 90248, 1024, 2048, 0xbaaafcc0
-0, 2066667, 2066667, 0, 230400, 0x5bbc2f63
+0, 2066667, 2066667, 66667, 230400, 0x5bbc2f63
1, 91272, 91272, 1024, 2048, 0xadc8017e
1, 92296, 92296, 1024, 2048, 0x4f4dffdc
1, 93320, 93320, 1024, 2048, 0x7ffbff48
-0, 2133333, 2133333, 0, 230400, 0x3becbfad
+0, 2133333, 2133333, 66667, 230400, 0x3becbfad
1, 94344, 94344, 1024, 2048, 0x2f990719
1, 95368, 95368, 1024, 2048, 0xe2caf65c
1, 96392, 96392, 1024, 2048, 0x825208e4
-0, 2200000, 2200000, 0, 230400, 0x0d77c977
+0, 2200000, 2200000, 66667, 230400, 0x0d77c977
1, 97416, 97416, 1024, 2048, 0xf563f13b
1, 98440, 98440, 1024, 2048, 0x855d03e9
1, 99464, 99464, 1024, 2048, 0x0ba9fa4b
-0, 2266667, 2266667, 0, 230400, 0x436cf4b2
+0, 2266667, 2266667, 66667, 230400, 0x436cf4b2
1, 100488, 100488, 1024, 2048, 0x83e1fb92
1, 101512, 101512, 1024, 2048, 0x1162f965
1, 102536, 102536, 1024, 2048, 0x0cfef73d
-0, 2333333, 2333333, 0, 230400, 0x39210f27
+0, 2333333, 2333333, 66667, 230400, 0x39210f27
1, 103560, 103560, 1024, 2048, 0x5688ff75
1, 104584, 104584, 1024, 2048, 0xf6c0ede9
1, 105608, 105608, 1024, 2048, 0xfdb20602
-0, 2400000, 2400000, 0, 230400, 0x242629d7
+0, 2400000, 2400000, 66667, 230400, 0x242629d7
1, 106632, 106632, 1024, 2048, 0x40c5f17b
1, 107656, 107656, 1024, 2048, 0x559600b1
1, 108680, 108680, 1024, 2048, 0xccc3f930
-0, 2466667, 2466667, 0, 230400, 0x771c2293
+0, 2466667, 2466667, 66667, 230400, 0x771c2293
1, 109704, 109704, 1024, 2048, 0xdc800045
1, 110728, 110728, 1024, 2048, 0xdce4fb3e
-0, 2533333, 2533333, 0, 230400, 0xec2af9a9
+0, 2533333, 2533333, 66667, 230400, 0xec2af9a9
1, 111752, 111752, 1024, 2048, 0x1e5efba9
1, 112776, 112776, 1024, 2048, 0x8c2e0832
1, 113800, 113800, 1024, 2048, 0x5c42f66d
-0, 2600000, 2600000, 0, 230400, 0x62cdc018
+0, 2600000, 2600000, 66667, 230400, 0x62cdc018
1, 114824, 114824, 1024, 2048, 0x08e20b1e
1, 115848, 115848, 1024, 2048, 0x4cf7f903
1, 116872, 116872, 1024, 2048, 0xe6b90794
-0, 2666667, 2666667, 0, 230400, 0xf02c8693
+0, 2666667, 2666667, 66667, 230400, 0xf02c8693
1, 117896, 117896, 1024, 2048, 0x5956f8e6
1, 118920, 118920, 1024, 2048, 0x6632ff16
1, 119944, 119944, 1024, 2048, 0x46c8fe11
-0, 2733333, 2733333, 0, 230400, 0x14436efb
+0, 2733333, 2733333, 66667, 230400, 0x14436efb
1, 120968, 120968, 1024, 2048, 0x7431f732
1, 121992, 121992, 1024, 2048, 0xa258049f
1, 123016, 123016, 1024, 2048, 0xdb71f00e
-0, 2800000, 2800000, 0, 230400, 0x248ad058
+0, 2800000, 2800000, 66667, 230400, 0x248ad058
1, 124040, 124040, 1024, 2048, 0xa89b0359
1, 125064, 125064, 1024, 2048, 0xe0aff0f2
1, 126088, 126088, 1024, 2048, 0xc33e0085
-0, 2866667, 2866667, 0, 230400, 0xe87f6c52
+0, 2866667, 2866667, 66667, 230400, 0xe87f6c52
1, 127112, 127112, 1024, 2048, 0x9d09f379
1, 128136, 128136, 1024, 2048, 0x8c78fd06
1, 129160, 129160, 1024, 2048, 0x532bfbdd
-0, 2933333, 2933333, 0, 230400, 0x6a0c196b
+0, 2933333, 2933333, 66667, 230400, 0x6a0c196b
1, 130184, 130184, 1024, 2048, 0xfc36f5cd
1, 131208, 131208, 1024, 2048, 0x2e8f0699
1, 132232, 132232, 1024, 2048, 0x52382578
@@ -169,52 +169,52 @@
1, 174216, 174216, 1024, 2048, 0xf86ff855
1, 175240, 175240, 1024, 2048, 0x6934061b
1, 176264, 176264, 136, 272, 0x4a458a45
-0, 4000000, 4000000, 0, 230400, 0x88c4d19a
+0, 4000000, 4000000, 125000, 230400, 0x88c4d19a
1, 176400, 176400, 1024, 2048, 0xdb0cfe95
1, 177424, 177424, 1024, 2048, 0xcff3fdf1
1, 178448, 178448, 1024, 2048, 0x070cf585
1, 179472, 179472, 1024, 2048, 0xe9b8007f
1, 180496, 180496, 1024, 2048, 0xc51ffd64
1, 181520, 181520, 1024, 2048, 0xede2fbf9
-0, 4125000, 4125000, 0, 230400, 0x05c1b733
+0, 4125000, 4125000, 125000, 230400, 0x05c1b733
1, 182544, 182544, 1024, 2048, 0x51510410
1, 183568, 183568, 1024, 2048, 0x198af498
1, 184592, 184592, 1024, 2048, 0xae3603a2
1, 185616, 185616, 1024, 2048, 0x6200f7a1
1, 186640, 186640, 1024, 2048, 0xe6e3fe32
-0, 4250000, 4250000, 0, 230400, 0x0446ec19
+0, 4250000, 4250000, 125000, 230400, 0x0446ec19
1, 187664, 187664, 1024, 2048, 0xb2e2fd77
1, 188688, 188688, 1024, 2048, 0x063dff2f
1, 189712, 189712, 1024, 2048, 0xa89ffe21
1, 190736, 190736, 1024, 2048, 0x9e6ffa6d
1, 191760, 191760, 1024, 2048, 0x028b004e
1, 192784, 192784, 1024, 2048, 0x57edfa23
-0, 4375000, 4375000, 0, 230400, 0x0f9b1744
+0, 4375000, 4375000, 125000, 230400, 0x0f9b1744
1, 193808, 193808, 1024, 2048, 0x6d8efe1f
1, 194832, 194832, 1024, 2048, 0x774bfe54
1, 195856, 195856, 1024, 2048, 0xa931fcfb
1, 196880, 196880, 1024, 2048, 0x3505004b
1, 197904, 197904, 1024, 2048, 0x5001f576
-0, 4500000, 4500000, 0, 230400, 0x30cf070a
+0, 4500000, 4500000, 125000, 230400, 0x30cf070a
1, 198928, 198928, 1024, 2048, 0x78ea049b
1, 199952, 199952, 1024, 2048, 0xd45bf733
1, 200976, 200976, 1024, 2048, 0x6395fead
1, 202000, 202000, 1024, 2048, 0xc126015e
1, 203024, 203024, 1024, 2048, 0xbecff8aa
-0, 4625000, 4625000, 0, 230400, 0x9175aaa9
+0, 4625000, 4625000, 125000, 230400, 0x9175aaa9
1, 204048, 204048, 1024, 2048, 0x0fea06c3
1, 205072, 205072, 1024, 2048, 0xdea6f351
1, 206096, 206096, 1024, 2048, 0x35b808f0
1, 207120, 207120, 1024, 2048, 0x5487ee73
1, 208144, 208144, 1024, 2048, 0xac69050e
1, 209168, 209168, 1024, 2048, 0xcc5ffb00
-0, 4750000, 4750000, 0, 230400, 0x597f5628
+0, 4750000, 4750000, 125000, 230400, 0x597f5628
1, 210192, 210192, 1024, 2048, 0x328c00cb
1, 211216, 211216, 1024, 2048, 0xa707fd82
1, 212240, 212240, 1024, 2048, 0xe442f73d
1, 213264, 213264, 1024, 2048, 0x545c0418
1, 214288, 214288, 1024, 2048, 0x744ff3f7
-0, 4875000, 4875000, 0, 230400, 0x38a45a85
+0, 4875000, 4875000, 125000, 230400, 0x38a45a85
1, 215312, 215312, 1024, 2048, 0x01aa04fd
1, 216336, 216336, 1024, 2048, 0xa885f7cd
1, 217360, 217360, 1024, 2048, 0xcfca04f4
diff --git a/tests/ref/fate/gif-disposal-restore b/tests/ref/fate/gif-disposal-restore
index b1282f61de..aca80c5e6d 100644
--- a/tests/ref/fate/gif-disposal-restore
+++ b/tests/ref/fate/gif-disposal-restore
@@ -4,5 +4,5 @@
#dimensions 0: 468x60
#sar 0: 0/1
0, 0, 0, 1, 112320, 0xb8afe429
-0, 1, 1, 1, 112320, 0xae588a4b
+0, 1, 1, 2, 112320, 0xae588a4b
0, 3, 3, 1, 112320, 0xccdd27b7
diff --git a/tests/ref/fate/gif-gray b/tests/ref/fate/gif-gray
index 18705d01fe..aa3969212d 100644
--- a/tests/ref/fate/gif-gray
+++ b/tests/ref/fate/gif-gray
@@ -3,39 +3,39 @@
#codec_id 0: rawvideo
#dimensions 0: 480x360
#sar 0: 0/1
-0, 0, 0, 1, 691200, 0xef6c0f3d
-0, 5, 5, 1, 691200, 0xc18b32de
-0, 7, 7, 1, 691200, 0x2395a3d7
-0, 9, 9, 1, 691200, 0x81dc3cf2
-0, 11, 11, 1, 691200, 0xabe2390e
-0, 13, 13, 1, 691200, 0xb2955c2a
-0, 15, 15, 1, 691200, 0x868d9ca2
-0, 17, 17, 1, 691200, 0x3016c2b6
-0, 19, 19, 1, 691200, 0x4501cffa
-0, 21, 21, 1, 691200, 0x8661d79e
-0, 25, 25, 1, 691200, 0xbc96d02e
-0, 27, 27, 1, 691200, 0x5f90bf5e
-0, 29, 29, 1, 691200, 0xf18da09a
-0, 31, 31, 1, 691200, 0x540467ce
-0, 33, 33, 1, 691200, 0x60d24012
-0, 35, 35, 1, 691200, 0x24323d36
-0, 37, 37, 1, 691200, 0x9e07c84b
-0, 39, 39, 1, 691200, 0xc18b32de
-0, 41, 41, 1, 691200, 0xef6c0f3d
-0, 46, 46, 1, 691200, 0xc9461045
-0, 48, 48, 1, 691200, 0x23ed4b99
-0, 50, 50, 1, 691200, 0x7e351d69
-0, 52, 52, 1, 691200, 0x0513e0aa
-0, 54, 54, 1, 691200, 0x28a4b6f2
-0, 56, 56, 1, 691200, 0xce10a94e
-0, 58, 58, 1, 691200, 0x63929d4e
-0, 60, 60, 1, 691200, 0xd26c9bb6
-0, 62, 62, 1, 691200, 0xb2a29842
-0, 66, 66, 1, 691200, 0x9fd69a16
-0, 68, 68, 1, 691200, 0x10f99e46
-0, 70, 70, 1, 691200, 0xea95a9fa
-0, 72, 72, 1, 691200, 0x97dbb9d6
-0, 74, 74, 1, 691200, 0xf4e9e2d6
-0, 76, 76, 1, 691200, 0x46b1230d
-0, 78, 78, 1, 691200, 0xb4a54ccd
-0, 80, 80, 1, 691200, 0x40cc103d
+0, 0, 0, 4, 691200, 0xef6c0f3d
+0, 5, 5, 2, 691200, 0xc18b32de
+0, 7, 7, 2, 691200, 0x2395a3d7
+0, 9, 9, 2, 691200, 0x81dc3cf2
+0, 11, 11, 2, 691200, 0xabe2390e
+0, 13, 13, 2, 691200, 0xb2955c2a
+0, 15, 15, 2, 691200, 0x868d9ca2
+0, 17, 17, 2, 691200, 0x3016c2b6
+0, 19, 19, 2, 691200, 0x4501cffa
+0, 21, 21, 4, 691200, 0x8661d79e
+0, 25, 25, 2, 691200, 0xbc96d02e
+0, 27, 27, 2, 691200, 0x5f90bf5e
+0, 29, 29, 2, 691200, 0xf18da09a
+0, 31, 31, 2, 691200, 0x540467ce
+0, 33, 33, 2, 691200, 0x60d24012
+0, 35, 35, 2, 691200, 0x24323d36
+0, 37, 37, 2, 691200, 0x9e07c84b
+0, 39, 39, 2, 691200, 0xc18b32de
+0, 41, 41, 5, 691200, 0xef6c0f3d
+0, 46, 46, 2, 691200, 0xc9461045
+0, 48, 48, 2, 691200, 0x23ed4b99
+0, 50, 50, 2, 691200, 0x7e351d69
+0, 52, 52, 2, 691200, 0x0513e0aa
+0, 54, 54, 2, 691200, 0x28a4b6f2
+0, 56, 56, 2, 691200, 0xce10a94e
+0, 58, 58, 2, 691200, 0x63929d4e
+0, 60, 60, 2, 691200, 0xd26c9bb6
+0, 62, 62, 4, 691200, 0xb2a29842
+0, 66, 66, 2, 691200, 0x9fd69a16
+0, 68, 68, 2, 691200, 0x10f99e46
+0, 70, 70, 2, 691200, 0xea95a9fa
+0, 72, 72, 2, 691200, 0x97dbb9d6
+0, 74, 74, 2, 691200, 0xf4e9e2d6
+0, 76, 76, 2, 691200, 0x46b1230d
+0, 78, 78, 2, 691200, 0xb4a54ccd
+0, 80, 80, 2, 691200, 0x40cc103d
diff --git a/tests/ref/fate/quickdraw b/tests/ref/fate/quickdraw
index 5746929502..44610498c8 100644
--- a/tests/ref/fate/quickdraw
+++ b/tests/ref/fate/quickdraw
@@ -9,7 +9,7 @@
0, 3, 3, 1, 921600, 0xc0e68764
0, 4, 4, 1, 921600, 0xc0e68764
0, 5, 5, 1, 921600, 0xc0e68764
-0, 7, 7, 1, 921600, 0x01a16629
+0, 7, 7, 2, 921600, 0x01a16629
0, 9, 9, 1, 921600, 0x01a16629
0, 10, 10, 1, 921600, 0x01a16629
0, 11, 11, 1, 921600, 0x01a16629
More information about the ffmpeg-cvslog
mailing list