How to Add Album Art to MP3 Using FFmpeg
Adding cover art to your MP3 files makes your music library visually appealing and compatible with modern media players. This guide provides a straightforward tutorial on how to use FFmpeg, a powerful command-line tool, to embed an album cover image directly into an MP3 audio file. You will learn the exact command-line syntax required to merge your audio and image files seamlessly without losing audio quality.
The Basic Command
To attach a JPEG or PNG image to an MP3 file as album art, open your terminal or command prompt and run the following command:
ffmpeg -i input.mp3 -i cover.jpg -map 0:a -map 1:v -c copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" output.mp3Command Breakdown
Understanding what each parameter does helps you customize the process:
-i input.mp3: Specifies the input audio file.-i cover.jpg: Specifies the image file you want to use as the album cover (usually JPEG or PNG).-map 0:a: Tells FFmpeg to take the audio stream from the first input file (input.mp3).-map 1:v: Tells FFmpeg to take the video (image) stream from the second input file (cover.jpg).-c copy: Copies both the audio and image streams directly without re-encoding them. This process is instant and preserves the original quality of your audio.-id3v2_version 3: Writes ID3v2.3 tags to the MP3 file. This is crucial because ID3v2.3 has the widest compatibility with Windows Explorer, macOS Finder, and various hardware media players.-metadata:s:v title="Album cover": Sets the metadata title for the video stream.-metadata:s:v comment="Cover (front)": Flags the image specifically as the front cover art so players recognize it correctly.
Batch Processing Multiple Files
If you have a folder of MP3 files and want to apply the same
cover.jpg to all of them, you can automate the process
using a simple command-line loop.
For Windows (Command Prompt):
for %i in (*.mp3) do ffmpeg -i "%i" -i cover.jpg -map 0:a -map 1:v -c copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" "tagged_%i"For macOS and Linux (Terminal):
for f in *.mp3; do ffmpeg -i "$f" -i cover.jpg -map 0:a -map 1:v -c copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" "tagged_$f"; doneThese loops will process every MP3 file in the directory and output a new version prefixed with “tagged_”, leaving your original files untouched.