[PR] avformat/wavenc: Omit JUNK for non-seekable -rf64 auto (PR #23992)

Daniel Verkamp via ffmpeg-devel <[email protected]> Mon, 03 Aug 2026 04:41:55 -0000
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <178573211589.59.9181799217694580680@29965ddac10e>
PR #23992 opened by Daniel Verkamp (drv)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23992
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23992.patch

The `-rf64 auto` option requires seeking in order to go back and convert
the reserved header space into a ds64 chunk when switching from RIFF to
RF64. If the output is not seekable, then it isn't possible to make use
of the space reserved with the JUNK chunk, so it is more reasonable to
just produce a regular RIFF with no JUNK chunk in this case, equivalent
to the `-rf64 never` option.



>From f544cae98869de4cd32770a4ff7a6fecbcc7f59d Mon Sep 17 00:00:00 2001
From: Daniel Verkamp <[email protected]>
Date: Wed, 22 Jul 2026 00:05:54 -0700
Subject: [PATCH] avformat/wavenc: Omit JUNK for non-seekable -rf64 auto

The `-rf64 auto` option requires seeking in order to go back and convert
the reserved header space into a ds64 chunk when switching from RIFF to
RF64. If the output is not seekable, then it isn't possible to make use
of the space reserved with the JUNK chunk, so it is more reasonable to
just produce a regular RIFF with no JUNK chunk in this case, equivalent
to the `-rf64 never` option.

Signed-off-by: Daniel Verkamp <[email protected]>
---
 libavformat/wavenc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index a8debf8faa..58579d2449 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -305,6 +305,10 @@ static int wav_write_header(AVFormatContext *s)
     AVIOContext *pb = s->pb;
     int64_t fmt;
 
+    if (wav->rf64 == RF64_AUTO && !(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
+        wav->rf64 = RF64_NEVER;
+    }
+
     if (wav->rf64 == RF64_ALWAYS) {
         ffio_wfourcc(pb, "RF64");
         avio_wl32(pb, -1); /* RF64 chunk size: use size in ds64 */
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]