Embed Cover Art in M4A and FLAC with FFmpeg

Adding album artwork to your digital music library helps organize and visually identify your tracks in media players. This guide provides a straightforward tutorial on how to use FFmpeg, a powerful command-line tool, to embed cover art images (such as JPEG or PNG) directly into M4A and FLAC audio files without re-encoding the audio.

How to Embed Cover Art in M4A Files

M4A files (which use the MP4 container) store cover art as a video stream marked as an attached picture.

To merge your M4A audio file and cover image, use the following command:

ffmpeg -i input.m4a -i cover.jpg -map 0:a -map 1:v -c copy -disposition:v attached_pic output.m4a

Command Breakdown:


How to Embed Cover Art in FLAC Files

FLAC files handle metadata differently than MP4 containers, but FFmpeg uses a very similar command structure to embed artwork as a FLAC picture block.

To add artwork to a FLAC file, run this command:

ffmpeg -i input.flac -i cover.jpg -map 0:a -map 1:v -c copy -disposition:v attached_pic output.flac

Command Breakdown:


Batch Processing Multiple Files (Optional)

If you have a folder of files and want to apply the same cover art (cover.jpg) to all of them, you can use a simple command-line loop.

For Windows (Command Prompt):

for %i in (*.mp3 *.m4a *.flac) do ffmpeg -i "%i" -i cover.jpg -map 0:a -map 1:v -c copy -disposition:v attached_pic "tagged_%i"

For Linux / macOS (Terminal):

for f in *.flac; do ffmpeg -i "$f" -i cover.jpg -map 0:a -map 1:v -c copy -disposition:v attached_pic "tagged_$f"; done