Change #264649
| Category | ffmpeg |
| Changed by | Daniel Verkamp <daniel@drv.nu> |
| Changed at | Thu 16 Apr 2026 11:12:45 |
| Repository | https://git.ffmpeg.org/ffmpeg.git |
| Project | ffmpeg |
| Branch | master |
| Revision | 8eae5de5af52039c8c0fad1cb709fec5388c3cf3 |
Comments
avformat/wavenc: Keep fmt chunk first for -rf64 auto When the WAV muxer's `-rf64 auto` option is used, the output is intended to be a normal WAV file if possible, only extended to RF64 format when the file size grows too large. This was accomplished by reserving space for the extra RF64-specific data using a standard JUNK chunk (ignored by readers), then overwriting the reserved space later with a ds64 chunk if needed. In the original rf64 auto implementation, the JUNK chunk was placed right after the RIFF/WAVE file header, before the fmt chunk; this is the design suggested by the "Achieving compatibility between BWF and RF64" section of the RF64 spec: RIFF 'WAVE' <JUNK chunk> <fmt-ck> ... However, this approach means that the fmt chunk is no longer in its conventional location at the beginning of the file, and some WAV-reading tools are confused by this layout. For example, the `file` tool is not able to show the format information for a file with the extra JUNK chunk before fmt. This change shuffles the order of the chunks for `-rf64 auto` mode so that the reserved space follows fmt instead of preceding it: RIFF 'WAVE' <fmt-ck> <JUNK chunk> ... With this small modification, tools expecting the fmt chunk to be the first chunk in the file work with files produced by `-rf64 auto`. This means the fmt chunk won't be in the location required by RF64, so if the automatic RF64 conversion is triggered, the fmt chunk needs to be relocated by rewriting it following the ds64 chunk during the conversion: RF64 'WAVE' <ds64 chunk> <fmt-ck> ...
Changed files
- libavformat/wavenc.c