FFmpeg, how to embed cover art (image) to .m4a

风流意气都作罢 提交于 2020-04-08 05:43:47

问题


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:


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



回答2:


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.




回答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



回答4:


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:0 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.



来源:https://stackoverflow.com/questions/17798709/ffmpeg-how-to-embed-cover-art-image-to-m4a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!