summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-11-07 22:11:14 +0100
committerCarl Hetherington <cth@carlh.net>2025-11-07 22:11:14 +0100
commitb4c12eaef029e6835bc3417b0e6169fdbbf458bb (patch)
treeda271702834ef6068afb04ea3c07010c2e1d8229 /src/lib
parent70537e7c6ee8e557ec665014c6e4e4246ca11434 (diff)
Use AV_CODEC_FLAG_BITEXACT when encoding audio.
Otherwise, for example, aacenc.c in ffmpeg calls put_bitstream_info() every so often. This writes the avcodec version string into the packet, so that when that string becomes longer there are fewer bits available for encoding the audio, slightly changing the rate calculations.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ffmpeg_file_encoder.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/ffmpeg_file_encoder.cc b/src/lib/ffmpeg_file_encoder.cc
index 1a1f8fed6..cfd82c7dc 100644
--- a/src/lib/ffmpeg_file_encoder.cc
+++ b/src/lib/ffmpeg_file_encoder.cc
@@ -73,6 +73,12 @@ public:
_codec_context->bit_rate = channels * 128 * 1024;
_codec_context->sample_fmt = sample_format;
_codec_context->sample_rate = frame_rate;
+ /* Without this flag the AAC encoder adds the libavcodec version number to some
+ * packets. When this version number gets longer (e.g. minor version from 9 -> 10)
+ * this slightly changes the rate calculation, giving a different output and breaking
+ * some of our tests.
+ */
+ _codec_context->flags |= AV_CODEC_FLAG_BITEXACT;
if (codec_name == "aac" && channels == 16) {
/* The default layout for AAC with 16 channels is not valid */
_codec_context->ch_layout = AV_CHANNEL_LAYOUT_HEXADECAGONAL;