2

I use Zeranoe build of FFmpeg. It converts mp3 files into m4a files just fine, as far as the audio stream is concerned, but I can't figure out a way to keep the songs album cover jpeg, which ffmpeg for some reason recognizes as

Stream #0:1: Video: mjpeg, yuvj420p, 200x200 [SAR 120:120 DAR 1:1]

included into the output.m4a file. When I use the following command line:

ffmpeg.exe -i 09.mp3 -map 0 -codec:a libvo_aacenc -ab 320k -ar 44100 -ac 2 -codec:v copy output.m4a

I get the no tag, codec not currently in the container error. And yet, when I run ffprobe with a .m4a file ctreated by iTunes, there it is:

Stream #0:1: Video: mjpeg, yuvj420p, 350x350 [SAR 72:72 DAR 1:1]

So, is there a way to copy the songs cover as well with ffmpeg conversion?

  • 1
    Please note that, according to FFmpeg wiki, libvo_aacenc is the worst AAC encoder(and even the worst audio encoder). Do NOT use libvo_aacenc in any circumstances. Instead, use libfdk_aac if possible (FFmpeg with libfdk_aac library is unredistributable, you have to build FFmpeg with libfdk_aac by yourself, ), libfaac is also acceptable if encoding with high bitrate. – Meow Oct 13 '14 at 13:22
6

As far as I'm concerned, there's no easy way to tell FFmpeg to set the album artwork for an MP4 container, which you'd typically use for AAC audio (.m4a). You can however use AtomicParsley to add the artwork later, via command line.

Here's how you can install AtomicParsley:

  • All operating systems have binaries from the SourceForge page
  • Linux distributions might have it in the packages, i.e. apt-get install atomicparsley
  • OS X through Homebrew with brew install atomicparsley

But first, we'll need to extract the artwork, e.g. as a JPEG file:

ffmpeg -i input.mp3 artwork.jpg

We can then use AtomicParsley to add the album artwork:

AtomicParsley output.m4a --artwork artwork.jpg 

This will not overwrite the original file but create a temporary file instead, e.g. output-temp-15274.m4a. If you want the original to be overwritten, add the --overWrite option to the command, e.g.:

AtomicParsley output.m4a --artwork artwork.jpg --overWrite

And voilà:

  • 1
    Great idea, slhck! Actually, I switched to qaac command line for mp3->m4a conversion. As an option it allows for artwork to be imported into the m4a on the spot. – user182551 Dec 26 '12 at 16:26
  • That's nice. I'm really not sure how to get FFmpeg to copy the artwork, there are no resources on this AFAIK and copying the video bitstream won't do. You can post your own solution as an answer here if you like, by the way. – slhck Dec 26 '12 at 17:00
0

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
0

Maybe this answer is coming a bit late but for those who are interested you can now keep all the streams only with ffmpeg like this:

# single file
ffmpeg -i /path/to/input.flac -acodec alac /path/to/output.m4a 
# all the .flac files in the folder
for m in *.flac; do ffmpeg -i "$m" -acodec alac "${m%.flac}.m4a"; done

For more information, here's the input/output streams:

Input:

Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 800x800 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc

Output:

Stream #0:0(und): Audio: alac (alac / 0x63616C61), 44100 Hz, stereo, s16p, 888 kb/s (default)
Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 800x800 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
0

Useful Windows batch file:

@ECHO OFF
REM Extracting album cover art and resizing to 300x300 into temporary file in PNG format
REM because FFMPEG can’t handle properly cover art directly...
ffmpeg -i %1 -an -vcodec png -vf scale=300:-1 __arttemp__.png -y
REM timeout 30

REM Converting audio to AAC LLC into .M4A container (Apple "Signed")
REM The FFMPEG does not apply LowPass filter, but there is not so 
REM much control over other parameters, but in tests was the righest
REM VBR rate (350~400 Kbps)...
ffmpeg -i %1 -acodec aac -ab 512k -ac 2 -vn %2 -y
REM timeout 30

REM Applying already cover art image extracted from original file
REM with this new "AtomicParsley"...
AtomicParsley %2 --artwork __arttemp__.png --overWrite
REM timeout 30

REM Deleting temporary cover art file...
del __arttemp__.jpg 
REM timeout 30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.