How to Add ID3v2 Tags to MP3 Using FFmpeg
This guide provides a straightforward tutorial on how to use FFmpeg to add or update ID3v2 metadata tags—specifically the Year, Genre, and Track Number—in an MP3 file. By using the command line, you can quickly embed this metadata into your audio files without needing to re-encode the audio stream, preserving the original sound quality.
To add or modify ID3v2 tags in an MP3 file, you will use FFmpeg’s
-metadata option along with the -c:a copy flag
to copy the audio stream without re-encoding.
The FFmpeg Command
Run the following command in your terminal or command prompt to apply the Year, Genre, and Track Number tags:
ffmpeg -i input.mp3 -metadata date="2023" -metadata genre="Synthwave" -metadata track="5" -id3v2_version 3 -c:a copy output.mp3Command Breakdown
-i input.mp3: Specifies the path to your source MP3 file.-metadata date="2023": Sets the “Year” field. In FFmpeg, thedatekey maps to the ID3v2 release time tag.-metadata genre="Synthwave": Sets the “Genre” field to your specified category.-metadata track="5": Sets the “Track Number” field. You can also use the format5/12to indicate track 5 out of 12.-id3v2_version 3: Forces FFmpeg to write ID3v2.3 tags instead of the default ID3v2.4. ID3v2.3 is highly recommended because it offers the widest compatibility across older car stereos, media players, and operating systems like Windows.-c:a copy: Instructs FFmpeg to copy the audio stream directly to the output file without re-encoding it. This process is instant and prevents any loss in audio quality.output.mp3: The name of the new MP3 file containing the updated metadata.
Verifying the Changes
To verify that the metadata was successfully written, you can inspect the newly created file using FFmpeg with this command:
ffprobe output.mp3The output will display the metadata block at the top, showing your
updated date, genre, and track
tags.