19

Is there any way to embed cover art to m4a files?

This one works well for mp3 but doesn't work for m4a

ffmpeg -i tests/in.m4a -i cover.jpg -map 0:0 -map 1:0 -acodec copy \
  -id3v2_version 3 tests/out.m4a
1
  • 1
    Why do you use ID3 formats in MPEG4 files. These are not compatible with each other. Commented Oct 8, 2019 at 11:12

4 Answers 4

20

mp4art from mp4v2 can also do this:

mp4art --add cover.jpg track.m4a

I tried mp4art, after adding the cover, the information from FFmpeg is like this:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fce82011400] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '01 - Welcome To New York.m4a':
  Metadata:
    major_brand     : M4A
    minor_version   : 512
    compatible_brands: isomiso2
    title           : Welcome To New York
    artist          : Taylor Swift
    album           : 1989 (Deluxe)
    date            : 2014
    encoder         : Lavf55.48.100
    genre           : Country & Folk
    track           : 1
    disc            : 1
  Duration: 00:03:32.65, start: 0.046444, bitrate: 250 kb/s
    Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 238 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
    Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg), 1400x1400 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
Input #1, image2, from 'Album Cover.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #1:0: Video: mjpeg, yuvj444p(pc, bt470bg), 1400x1400 [SAR 72:72 DAR 1:1], 25 tbr, 25 tbn, 25 tbc

It seems that 1 file has 2 input formats (1 m4a, 1 image2), I think ffmpeg should be able to do the same thing by itself instead of using a separate tool to add cover image, but I haven't figure out how.

Sign up to request clarification or add additional context in comments.

Comments

19

It is possible with ffmpeg by specifying the attached_pic attribute on the image source via the -disposition parameter.

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

Tested with ffmpeg 4.2.2.

A similar command is also given as an example in the ffmpeg docs, however be careful that the example is for adding covers to videos but not audio files. The -disposition parameter fails silently if the wrong stream is selected.

3 Comments

failure: [ipod @ 0x7fd692008200] Could not find tag for codec png in stream #1, codec not currently supported in container Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument Error initializing output stream 0:1 -- Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #1:0 -> #0:1 (copy) Last message repeated 1 times
Adding -id3v2_version 3 seems to be doing the trick on ffmpeg 4.4
I was having the same error as @ChaitanyaBapat and turns out the issue is in the -disposition:v:1. Simply replacing it with -disposition:v:0 or even -disposition:v did the trick. This led me to conclude that the mapping with -map is not even necessary. In other words, the following is sufficient: ffmpeg -i input.m4a -i image.jpg -c copy -disposition:v attached_pic output4.m4a Tested with ffmpeg 4.3.6.
7

FFmpeg has an open issue on this functionality. In the meantime, covers can be added with the TagEditor project. To add:

tageditor -s cover=ju.jpg --max-padding 100000 -f ki.m4a

To remove:

tageditor -s cover= --max-padding 100000 -f ki.m4a

1 Comment

It has nice GUI too :-)
3

A little bit extended version for embedding album art with atomicparsley. Tested on Mac OS X. It assumes there is folder.jpg file in the current directory. AtomicParsley creates temp files with embedded media in the same folder. There is a flag --overWrite which is supposed to change this behavior, but for some reason this doesn't work for me. So we will need to remove the original files afterwards. Note, that the script will remove all the files which do not coontain temp in their filename. So be cautious (or modify the script). Finally, the script renames newly created files to remove -temp- part from their filenames.

for f in *.m4a
do
    atomicparsley "$f" --artwork folder.jpg
done
rm !(*temp*)
for f in *.m4a
do
    g=${f//-temp*./.}
    mv "$f" "$g"
done

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.