Edit MP3 ID3 Tags Using FFmpeg on Linux
FFmpeg is a powerful command-line tool that allows you to easily view, add, modify, and strip ID3 metadata tags from MP3 files on a Linux system. This article provides a quick overview of how to manipulate audio metadata using FFmpeg, covering everything from basic tag editing for titles and artists to advanced operations like embedding album art and batch-processing entire directories.
Viewing Existing ID3 Tags
Before changing any metadata, it is helpful to see what tags are already embedded in your audio file. You can display this information by running FFmpeg without specifying an output file.
ffmpeg -i input.mp3Because FFmpeg outputs a lot of configuration details by default, you
can clean up the terminal output to show only the metadata by adding the
-hide_banner flag:
ffmpeg -i input.mp3 -hide_bannerBasic Metadata Editing
To edit or add basic ID3 tags, you use the -metadata
flag followed by the key-value pair (key="value"). The
-c:a copy option is crucial here because it tells FFmpeg to
copy the audio stream without re-encoding it, making the process
instantaneous and preserving original audio quality.
ffmpeg -i input.mp3 -c:a copy -metadata title="Song Title" -metadata artist="Artist Name" output.mp3Commonly Used Metadata Keys
title— The name of the track.artist— The performing artist.album— The album the track belongs to.date— The release year.genre— The musical genre.track— The track number (e.g., “01” or “1/12”).
Adding Album Artwork
Adding a cover image to an MP3 file requires mapping a static image file (like a JPEG or PNG) alongside the audio file into the output container.
ffmpeg -i input.mp3 -i cover.jpg -map 0:0 -map 1:0 -c copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" output.mp3-map 0:0and-map 1:0tell FFmpeg to take the first stream from the first input (audio) and the first stream from the second input (image).-id3v2_version 3ensures the metadata is written in ID3v2.3 format, which offers the best compatibility across various media players and devices.
Removing ID3 Tags
If you want to strip all existing metadata and start fresh, you can
use the -map_metadata -1 flag. This instructs FFmpeg to
ignore any metadata from the input file when generating the output
file.
ffmpeg -i input.mp3 -c:a copy -map_metadata -1 output.mp3Batch Editing Multiple Files
If you have an entire album or folder of MP3 files that need the same
album or artist tags, you can automate the task using a simple Bash
for loop in your Linux terminal.
for file in *.mp3; do
ffmpeg -i "$file" -c:a copy -metadata artist="Unified Artist Name" -metadata album="Greatest Hits" "edited_$file"
doneThis script loops through every MP3 file in the current working directory, applies the specified artist and album tags, and saves the new files with an “edited_” prefix, leaving your original files untouched.