Commit 92f5c7f211 for ffmpeg
commit 92f5c7f211b9e7ee70ff172f373219e25e028bcc
Author: Hunter Kvalevog <hunter@kvog.sh>
Date: Wed Sep 23 19:23:14 2026 -0500
avformat/wavenc: disallow write_peak=only with RF64
Prior to this commit, the following command would generate an RF64 file
with a broken header:
$ ffmpeg -i inp.wav -write_peak only -rf64 always out.wav
There is no good reason to allow these options together. RF64 requires
a ds64 chunk, but write_peak=only omits all chunks except for levl.
Since 8eae5de5af, this combination will also write RF64 fmt values over
the peak envelope chunk. Rather than adding yet another check for
PEAK_ONLY, this commit forbids rf64=always and downgrades rf64=auto to
rf64=never.
Signed-off-by: Hunter Kvalevog <hunter@kvog.sh>
diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index 58579d2449..55d702fb2c 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -145,6 +145,22 @@ static void bwf_write_bext_chunk(AVFormatContext *s)
ff_end_tag(s->pb, bext);
}
+static av_cold int wav_init(AVFormatContext *s)
+{
+ WAVMuxContext *wav = s->priv_data;
+
+ if (wav->write_peak == PEAK_ONLY) {
+ if (wav->rf64 == RF64_ALWAYS) {
+ av_log(s, AV_LOG_ERROR, "write_peak=only is not compatible with RF64\n");
+ return AVERROR(EINVAL);
+ }
+ if (wav->rf64 == RF64_AUTO)
+ wav->rf64 = RF64_NEVER;
+ }
+
+ return 0;
+}
+
static av_cold void wav_deinit(AVFormatContext *s)
{
WAVMuxContext *wav = s->priv_data;
@@ -533,6 +549,7 @@ const FFOutputFormat ff_wav_muxer = {
.p.audio_codec = AV_CODEC_ID_PCM_S16LE,
.p.video_codec = AV_CODEC_ID_NONE,
.p.subtitle_codec = AV_CODEC_ID_NONE,
+ .init = wav_init,
.write_header = wav_write_header,
.write_packet = wav_write_packet,
.write_trailer = wav_write_trailer,