How to add album art with ffmpeg?
Asked Answered
K

5

55

I've been stuck in adding album art to mp3 files.

I've already researched and Googled this issue but haven't found a solution yet. The ffmpeg documentation recommends this script to add image (album art) to mp3:

ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3

But it doesn't work. My console output is:

Unrecognized option 'c'
Failed to set value 'copy' for option 'c'

I looked for another solution and got this:

ffmpeg -i input.mp3 -i cover.png -map 0:0 -map 1:0 -c copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3

This returns the same output:

Unrecognized option 'c'
Failed to set value 'copy' for option 'c'

Anybody can help me, please?

I am using ubuntu 12.04 and ffmpeg version 0.8.6-4:0.8.6-0.

Thanks.

Kepner answered 10/9, 2013 at 4:57 Comment(3)
just about the -c ? have you try '-acodec copy' as you use an old version... and try to update !Reynolds
I already tried to replace -c with -codec but return of output is same : Unrecognized option 'codec' Failed to set value 'copy' for option 'codec'Kepner
You're using an old, fake version of ffmpeg that is not supported by the online documentation. See Who can tell me the difference and relation between ffmpeg, libav, and avconv?. You can get recent, real ffmpeg by following a step-by-step guide to compile ffmpeg, or by simply using a Linux build of ffmpeg.Helwig
R
66

With Recent version,

ffmpeg -i in.mp3 -i test.png -map 0:0 -map 1:0 -c copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" out.mp3

Use -map to associate input stream to the output
Use -c copy to directly demux/remux
The -id3v2_version 3 is what is missing in your command line. Note that that wil write an IDV2.3 but you can ask for a 2.4 (-id3v2_version 4)

with the -id3v2_version 3 option the -metadataoption will be well interpreted

Note: the metadata comment is case-sensitive.

Reynolds answered 10/9, 2013 at 11:52 Comment(4)
One '-metadata:s:v' option above was lacking the '-'. This gave me an error "[NULL @ 0x7ffd7400fa00] Unable to find a suitable output format for 'metadata:s:v' || metadata:s:v: Invalid argument". I corrected it in the answer.Tiu
comment="Cover (front)" - not comment="Cover (Front)"Pro
I have to say that should not skip the "-id3v2_version 3" parameter. Without it the cover will be visible on Mac, but not on Windows.Ruminate
Using this method album art shows in some programs (vlc and totem) but not in others (rhythmbox and nautilus) which normally show album art for mp3 files.Tonguing
E
25

There is an important thing to notice here, that made me loose an hour of work:

ffmpeg -i in.mp3 -i test.jpeg -map 0:0 -map 1:0 -codec copy -id3v2_version 3 \ 
-metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" out.mp3

The f in comment="Cover (front)" must be lowercase. If not, the picture type in the ID3 header will not be set !

Another hint that might help somebody: To avoid that a JPEG cover image is converted to png, you have to set -codec copy.

Everyone answered 16/2, 2018 at 15:5 Comment(0)
T
9

This is how I converted a different input/source format (in this example video.ts) to MP3 and also added cover art to the result MP3 all in one go (one command):

ffmpeg -ss 5 -to 13 -i video.ts -i logo.png -map 0:a -map 1:0 -c:1 copy -b:a 320k -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" result.mp3

NOTE

If ffmpeg fails with an error, try to omit -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" from the command.

Description of options used in the command:

Option Required? Description
-ss 5 OPTIONAL specifies the start time (in seconds) from the input
-to 13 OPTIONAL specifies the end time (in seconds) from the input
-i video.ts - the first input (file to convert)
-i logo.png - the second input (album/cover art)
-map 0:a - from the input 0 (aka video.ts), selects the audio (a)
-map 1:0 - from the input 1 (aka logo.png), selects the first stream (0)
-c:1 copy OPTIONAL sets the codec for second input (image) to copy (no conversion)
b:a 320k OPTIONAL sets the bitrate for audio stream to 320k; see accepted values in footnote 1

Thanks to konsolebox for this Stack Overflow answer.

1: Valid bitrates for b:a option:
8k|16k|24k|32k|40k|48k|64k|80k|96k|112k|128k|160k|192k|224k|256k|320k

Thunderpeal answered 13/9, 2022 at 16:54 Comment(0)
S
3

the problem is that you are not defining what codec you want to copy. In case of the audio should be -c:a copy the cover is recognized as video (go figure!!), so -c:v copy

ffmpeg -i audio-in.mp3 -i picture.png -c:a copy -c:v copy -map 0:0 -map 1:0 -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" audio-out.mp3
Sheathe answered 24/5, 2019 at 11:46 Comment(0)
A
1

Can't comment but Mahozad's answer did the trick for me, just adding -map 0:a (instead of just "0" or "0:0") and -map 1:0 without anything else:

ffmpeg -i url.m3u8 -i url.jpg -map 0:a -map 1:0 file:output.mp3

Autrey answered 2/2, 2023 at 4:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.