How to Edit WAV Metadata and Extra Fields in FFmpeg
This article provides a quick overview of how to manipulate WAV
(Waveform Audio File Format) header fields, metadata, and extra chunks
using FFmpeg. While FFmpeg includes an extrafield filter,
this specific filter is designed for video bitstreams rather than audio.
To modify the extra format fields, Broadcast Wave Format (BWF) data, and
metadata chunks of a WAV file, you must use FFmpeg’s dedicated audio
muxer options and metadata flags.
Clarifying the “extrafield” Filter in FFmpeg
In FFmpeg, extrafield is a video
filter, not an audio filter. It is used to write or modify
extra field information (such as interlacing flags) in video
packets.
If you attempt to use -vf extrafield or
-af extrafield on a WAV audio file, FFmpeg will return an
error because the filter is incompatible with audio streams. To
manipulate the format header fields or extra metadata chunks of a WAV
file, you must use the audio-specific methods detailed below.
1.
Controlling the WAV Format Extension Field (cbSize)
Standard WAV files use the WAVEFORMATEX header, which
contains an “extra” field specifying the size of extra format
information (cbSize). For multi-channel or high-definition
audio, FFmpeg uses WAVEFORMATEXTENSIBLE (which includes a
22-byte extra extension field).
You can control how FFmpeg writes these extra header fields using the
-waveformat private muxer option:
Force standard WAV headers (compatible mode): This minimizes the use of the extra format extension field, keeping the file compatible with older playback systems.
ffmpeg -i input.wav -waveformat compatible output.wavForce extensible WAV headers (strict mode): This forces the use of the
WAVEFORMATEXTENSIBLEheader, writing the extra format extension fields into the file header.ffmpeg -i input.wav -waveformat strict output.wav
2. Writing Broadcast Wave Format (BWF) Extra Chunks
WAV files often carry extra metadata in a Broadcast Wave Format (BWF)
chunk, known as the bext chunk. You can enable and
manipulate this extra metadata field using the -write_bext
option.
Enable the BEXT chunk and add custom metadata:
ffmpeg -i input.wav -write_bext 1 -metadata description="Recording Session 1" -metadata originator="Engineer Name" output.wav
Common BWF-specific metadata keys you can manipulate include: *
description * originator *
originator_reference * origination_date *
origination_time * umid (Unique Material
Identifier)
3. Adding, Editing, or Stripping General WAV Metadata Chunks
To edit standard metadata fields (like Title, Artist, or Genre)
stored inside the WAV list info chunk, use the -metadata
flag:
Add or modify standard fields:
ffmpeg -i input.wav -metadata title="Song Title" -metadata artist="Artist Name" output.wavStrip all extra metadata and custom chunks: If you want a clean, raw WAV file with no extra metadata chunks or extension fields, use the
-map_metadata -1flag:ffmpeg -i input.wav -map_metadata -1 output.wav