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.mp3

Because 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_banner

Basic 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.mp3

Commonly Used Metadata Keys


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

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.mp3

Batch 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"
done

This 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.