[FFmpeg-cvslog] fftools/ffmpeg_enc: only use fallback framerate when encoding CFR
Anton Khirnov
git at videolan.org
Wed Aug 30 13:00:15 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Jul 21 16:13:58 2023 +0200| [411ada649f11724111fa3dfec833876f7989e01f] | committer: Anton Khirnov
fftools/ffmpeg_enc: only use fallback framerate when encoding CFR
When no output video framerate is specified by the user with -r or can
be inferred from the filtergraph, encoder setup will arbitrarily decide
that the framerate is 25fps. However, making up any framerate value for
VFR encoding is at best unnecessary.
Changes the results of the sub2video tests, where the input timebase is
now used instead of 1/25.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=411ada649f11724111fa3dfec833876f7989e01f
---
fftools/ffmpeg_enc.c | 29 +++---
tests/ref/fate/sub2video_basic | 182 +++++++++++++++++-----------------
tests/ref/fate/sub2video_time_limited | 8 +-
3 files changed, 112 insertions(+), 107 deletions(-)
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 4b5bd3d9b4..80a49fe606 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -231,20 +231,24 @@ static int enc_choose_timebase(OutputStream *ost, AVFrame *frame)
fr = ost->frame_rate;
if (!fr.num)
fr = fd->frame_rate_filter;
- if (!fr.num && !ost->max_frame_rate.num) {
- fr = (AVRational){25, 1};
- av_log(ost, AV_LOG_WARNING,
- "No information "
- "about the input framerate is available. Falling "
- "back to a default value of 25fps. Use the -r option "
- "if you want a different framerate.\n");
- }
- if (ost->max_frame_rate.num &&
- (av_q2d(fr) > av_q2d(ost->max_frame_rate) ||
- !fr.den))
- fr = ost->max_frame_rate;
+ if (ost->is_cfr) {
+ if (!fr.num && !ost->max_frame_rate.num) {
+ fr = (AVRational){25, 1};
+ av_log(ost, AV_LOG_WARNING,
+ "No information "
+ "about the input framerate is available. Falling "
+ "back to a default value of 25fps. Use the -r option "
+ "if you want a different framerate.\n");
+ }
+
+ if (ost->max_frame_rate.num &&
+ (av_q2d(fr) > av_q2d(ost->max_frame_rate) ||
+ !fr.den))
+ fr = ost->max_frame_rate;
+ }
+ if (fr.num > 0) {
if (enc->codec->supported_framerates && !ost->force_fps) {
int idx = av_find_nearest_q_idx(fr, enc->codec->supported_framerates);
fr = enc->codec->supported_framerates[idx];
@@ -254,6 +258,7 @@ static int enc_choose_timebase(OutputStream *ost, AVFrame *frame)
av_reduce(&fr.num, &fr.den,
fr.num, fr.den, 65535);
}
+ }
if (av_q2d(fr) > 1e3 && ost->vsync_method != VSYNC_PASSTHROUGH &&
(ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR ||
diff --git a/tests/ref/fate/sub2video_basic b/tests/ref/fate/sub2video_basic
index 5f72e292c9..a6eb1a34ea 100644
--- a/tests/ref/fate/sub2video_basic
+++ b/tests/ref/fate/sub2video_basic
@@ -1,95 +1,95 @@
-#tb 0: 1/25
+#tb 0: 1/1000
#media_type 0: video
#codec_id 0: rawvideo
#dimensions 0: 720x480
#sar 0: 0/1
-0, 3312, 3312, 1, 1382400, 0x00000000
-0, 3312, 3312, 1, 1382400, 0x8c93c2ba
-0, 3436, 3436, 1, 1382400, 0x00000000
-0, 3684, 3684, 1, 1382400, 0xb02e32ca
-0, 3802, 3802, 1, 1382400, 0x00000000
-0, 4520, 4520, 1, 1382400, 0x83b71116
-0, 4584, 4584, 1, 1382400, 0x00000000
-0, 4586, 4586, 1, 1382400, 0x85547fd1
-0, 4645, 4645, 1, 1382400, 0x00000000
-0, 4648, 4648, 1, 1382400, 0x00000000
-0, 4648, 4648, 1, 1382400, 0xb6a8f181
-0, 4715, 4715, 1, 1382400, 0x00000000
-0, 4717, 4717, 1, 1382400, 0xb64d1a2c
-0, 4748, 4748, 1, 1382400, 0x00000000
-0, 4750, 4750, 1, 1382400, 0x7b37ecf3
-0, 4792, 4792, 1, 1382400, 0x00000000
-0, 4993, 4993, 1, 1382400, 0xdc025bd1
-0, 5027, 5027, 1, 1382400, 0x00000000
-0, 5029, 5029, 1, 1382400, 0x688b294d
-0, 5068, 5068, 1, 1382400, 0x00000000
-0, 5070, 5070, 1, 1382400, 0xa2b33d1b
-0, 5117, 5117, 1, 1382400, 0x00000000
-0, 5119, 5119, 1, 1382400, 0xb3e525e3
-0, 5168, 5168, 1, 1382400, 0x00000000
-0, 5170, 5170, 1, 1382400, 0xaa8fbdd7
-0, 5216, 5216, 1, 1382400, 0x00000000
-0, 5218, 5218, 1, 1382400, 0x7b7f26dd
-0, 5249, 5249, 1, 1382400, 0x00000000
-0, 5251, 5251, 1, 1382400, 0x15e2f836
-0, 5289, 5289, 1, 1382400, 0x00000000
-0, 5291, 5291, 1, 1382400, 0x0fee9b0c
-0, 5358, 5358, 1, 1382400, 0x00000000
-0, 5360, 5360, 1, 1382400, 0x89d62791
-0, 5429, 5429, 1, 1382400, 0x00000000
-0, 5431, 5431, 1, 1382400, 0xa6a9fd74
-0, 5490, 5490, 1, 1382400, 0x00000000
-0, 5491, 5491, 1, 1382400, 0x7896178d
-0, 5537, 5537, 1, 1382400, 0x00000000
-0, 5588, 5588, 1, 1382400, 0x01751a52
-0, 5647, 5647, 1, 1382400, 0x00000000
-0, 5688, 5688, 1, 1382400, 0xa3959c6f
-0, 5770, 5770, 1, 1382400, 0x00000000
-0, 5772, 5772, 1, 1382400, 0x3d3ea47b
-0, 5826, 5826, 1, 1382400, 0x00000000
-0, 5828, 5828, 1, 1382400, 0x593f8b24
-0, 5931, 5931, 1, 1382400, 0x00000000
-0, 5933, 5933, 1, 1382400, 0x171f05ba
-0, 6001, 6001, 1, 1382400, 0x00000000
-0, 6003, 6003, 1, 1382400, 0xb014cdf1
-0, 6054, 6054, 1, 1382400, 0x00000000
-0, 6839, 6839, 1, 1382400, 0xd918e667
-0, 6880, 6880, 1, 1382400, 0x00000000
-0, 7386, 7386, 1, 1382400, 0xc9406331
-0, 7419, 7419, 1, 1382400, 0x00000000
-0, 7501, 7501, 1, 1382400, 0xaf08b10d
-0, 7549, 7549, 1, 1382400, 0x00000000
-0, 7551, 7551, 1, 1382400, 0x00000000
-0, 7551, 7551, 1, 1382400, 0x853a9d93
-0, 7589, 7589, 1, 1382400, 0x00000000
-0, 7605, 7605, 1, 1382400, 0x7491a87d
-0, 7647, 7647, 1, 1382400, 0x00000000
-0, 7649, 7649, 1, 1382400, 0xf7383c58
-0, 7697, 7697, 1, 1382400, 0x00000000
-0, 7699, 7699, 1, 1382400, 0xe66be411
-0, 7743, 7743, 1, 1382400, 0x00000000
-0, 8032, 8032, 1, 1382400, 0xd6850362
-0, 8082, 8082, 1, 1382400, 0x00000000
-0, 8084, 8084, 1, 1382400, 0x3e1ed109
-0, 8115, 8115, 1, 1382400, 0x00000000
-0, 8116, 8116, 1, 1382400, 0x39c1b7bd
-0, 8160, 8160, 1, 1382400, 0x00000000
-0, 8180, 8180, 1, 1382400, 0x35b85f2e
-0, 8207, 8207, 1, 1382400, 0x00000000
-0, 8209, 8209, 1, 1382400, 0x00000000
-0, 8209, 8209, 1, 1382400, 0x83f103e5
-0, 8247, 8247, 1, 1382400, 0x00000000
-0, 8249, 8249, 1, 1382400, 0xbc1ca9b3
-0, 8278, 8278, 1, 1382400, 0x00000000
-0, 8281, 8281, 1, 1382400, 0x94d4a51e
-0, 8321, 8321, 1, 1382400, 0x00000000
-0, 8323, 8323, 1, 1382400, 0xf88cdfde
-0, 8367, 8367, 1, 1382400, 0x00000000
-0, 8565, 8565, 1, 1382400, 0xdd51423b
-0, 8611, 8611, 1, 1382400, 0x00000000
-0, 8669, 8669, 1, 1382400, 0x08259fa4
-0, 8708, 8708, 1, 1382400, 0x00000000
-0, 8941, 8941, 1, 1382400, 0x1663fa34
-0, 8994, 8994, 1, 1382400, 0x00000000
-0, 8996, 8996, 1, 1382400, 0xda2ceb55
-0, 9027, 9027, 1, 1382400, 0x00000000
+0, 132499, 132499, 0, 1382400, 0x00000000
+0, 132499, 132499, 0, 1382400, 0x8c93c2ba
+0, 137459, 137459, 0, 1382400, 0x00000000
+0, 147355, 147355, 0, 1382400, 0xb02e32ca
+0, 152088, 152088, 0, 1382400, 0x00000000
+0, 180797, 180797, 0, 1382400, 0x83b71116
+0, 183357, 183357, 0, 1382400, 0x00000000
+0, 183433, 183433, 0, 1382400, 0x85547fd1
+0, 185799, 185799, 0, 1382400, 0x00000000
+0, 185909, 185909, 0, 1382400, 0x00000000
+0, 185910, 185910, 0, 1382400, 0xb6a8f181
+0, 188606, 188606, 0, 1382400, 0x00000000
+0, 188663, 188663, 0, 1382400, 0xb64d1a2c
+0, 189925, 189925, 0, 1382400, 0x00000000
+0, 190014, 190014, 0, 1382400, 0x7b37ecf3
+0, 191675, 191675, 0, 1382400, 0x00000000
+0, 199724, 199724, 0, 1382400, 0xdc025bd1
+0, 201089, 201089, 0, 1382400, 0x00000000
+0, 201175, 201175, 0, 1382400, 0x688b294d
+0, 202733, 202733, 0, 1382400, 0x00000000
+0, 202819, 202819, 0, 1382400, 0xa2b33d1b
+0, 204684, 204684, 0, 1382400, 0x00000000
+0, 204762, 204762, 0, 1382400, 0xb3e525e3
+0, 206730, 206730, 0, 1382400, 0x00000000
+0, 206806, 206806, 0, 1382400, 0xaa8fbdd7
+0, 208637, 208637, 0, 1382400, 0x00000000
+0, 208716, 208716, 0, 1382400, 0x7b7f26dd
+0, 209978, 209978, 0, 1382400, 0x00000000
+0, 210051, 210051, 0, 1382400, 0x15e2f836
+0, 211575, 211575, 0, 1382400, 0x00000000
+0, 211644, 211644, 0, 1382400, 0x0fee9b0c
+0, 214306, 214306, 0, 1382400, 0x00000000
+0, 214380, 214380, 0, 1382400, 0x89d62791
+0, 217144, 217144, 0, 1382400, 0x00000000
+0, 217225, 217225, 0, 1382400, 0xa6a9fd74
+0, 219591, 219591, 0, 1382400, 0x00000000
+0, 219652, 219652, 0, 1382400, 0x7896178d
+0, 221483, 221483, 0, 1382400, 0x00000000
+0, 223531, 223531, 0, 1382400, 0x01751a52
+0, 225863, 225863, 0, 1382400, 0x00000000
+0, 227510, 227510, 0, 1382400, 0xa3959c6f
+0, 230809, 230809, 0, 1382400, 0x00000000
+0, 230872, 230872, 0, 1382400, 0x3d3ea47b
+0, 233033, 233033, 0, 1382400, 0x00000000
+0, 233124, 233124, 0, 1382400, 0x593f8b24
+0, 237220, 237220, 0, 1382400, 0x00000000
+0, 237303, 237303, 0, 1382400, 0x171f05ba
+0, 240033, 240033, 0, 1382400, 0x00000000
+0, 240106, 240106, 0, 1382400, 0xb014cdf1
+0, 242165, 242165, 0, 1382400, 0x00000000
+0, 273556, 273556, 0, 1382400, 0xd918e667
+0, 275217, 275217, 0, 1382400, 0x00000000
+0, 295445, 295445, 0, 1382400, 0xc9406331
+0, 296776, 296776, 0, 1382400, 0x00000000
+0, 300049, 300049, 0, 1382400, 0xaf08b10d
+0, 301949, 301949, 0, 1382400, 0x00000000
+0, 302034, 302034, 0, 1382400, 0x00000000
+0, 302035, 302035, 0, 1382400, 0x853a9d93
+0, 303559, 303559, 0, 1382400, 0x00000000
+0, 304203, 304203, 0, 1382400, 0x7491a87d
+0, 305898, 305898, 0, 1382400, 0x00000000
+0, 305947, 305947, 0, 1382400, 0xf7383c58
+0, 307881, 307881, 0, 1382400, 0x00000000
+0, 307957, 307957, 0, 1382400, 0xe66be411
+0, 309720, 309720, 0, 1382400, 0x00000000
+0, 321295, 321295, 0, 1382400, 0xd6850362
+0, 323263, 323263, 0, 1382400, 0x00000000
+0, 323356, 323356, 0, 1382400, 0x3e1ed109
+0, 324584, 324584, 0, 1382400, 0x00000000
+0, 324640, 324640, 0, 1382400, 0x39c1b7bd
+0, 326403, 326403, 0, 1382400, 0x00000000
+0, 327193, 327193, 0, 1382400, 0x35b85f2e
+0, 328285, 328285, 0, 1382400, 0x00000000
+0, 328360, 328360, 0, 1382400, 0x00000000
+0, 328361, 328361, 0, 1382400, 0x83f103e5
+0, 329885, 329885, 0, 1382400, 0x00000000
+0, 329946, 329946, 0, 1382400, 0xbc1ca9b3
+0, 331106, 331106, 0, 1382400, 0x00000000
+0, 331230, 331230, 0, 1382400, 0x94d4a51e
+0, 332857, 332857, 0, 1382400, 0x00000000
+0, 332924, 332924, 0, 1382400, 0xf88cdfde
+0, 334687, 334687, 0, 1382400, 0x00000000
+0, 342600, 342600, 0, 1382400, 0xdd51423b
+0, 344431, 344431, 0, 1382400, 0x00000000
+0, 346771, 346771, 0, 1382400, 0x08259fa4
+0, 348329, 348329, 0, 1382400, 0x00000000
+0, 357640, 357640, 0, 1382400, 0x1663fa34
+0, 359767, 359767, 0, 1382400, 0x00000000
+0, 359834, 359834, 0, 1382400, 0xda2ceb55
+0, 361096, 361096, 0, 1382400, 0x00000000
diff --git a/tests/ref/fate/sub2video_time_limited b/tests/ref/fate/sub2video_time_limited
index 9fb6fb06f9..c7d48d639f 100644
--- a/tests/ref/fate/sub2video_time_limited
+++ b/tests/ref/fate/sub2video_time_limited
@@ -1,8 +1,8 @@
-#tb 0: 1/25
+#tb 0: 1/90000
#media_type 0: video
#codec_id 0: rawvideo
#dimensions 0: 1920x1080
#sar 0: 0/1
-0, 2, 2, 1, 8294400, 0x00000000
-0, 2, 2, 1, 8294400, 0xa87c518f
-0, 10, 10, 1, 8294400, 0xa87c518f
+0, 6072, 6072, 0, 8294400, 0x00000000
+0, 6072, 6072, 0, 8294400, 0xa87c518f
+0, 36101, 36101, 0, 8294400, 0xa87c518f
More information about the ffmpeg-cvslog
mailing list