Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting audio files and preserving album artwork with ffmpeg

Tags:

php

ffmpeg

audio

I am wondering if it is possible to convert audio files which have embedded artwork to MP3 and preserve the artwork using ffmpeg? I have ffmpeg installed on my server, and the conversion to MP3 works fine, including all metadata apart from embedded artwork.

Thanks,

Nick

like image 868
Nick Avatar asked May 16 '12 21:05

Nick


1 Answers

FFmpeg can handle artwork embedded in mp3s. From the docs on mp3:

The muxer supports writing ID3v2 attached pictures (APIC frames). The pictures are supplied to the muxer in form of a video stream with a single packet. There can be any number of those streams, each will correspond to a single APIC frame. The stream metadata tags title and comment map to APIC description and picture type respectively. See http://id3.org/id3v2.4.0-frames for allowed picture types.

...

Attach a picture to an mp3:

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

Merely preserving an attached picture should be a simple matter of copying the picture stream to the mp3, though you don't mention what format you're converting from and some might store artwork differently.

like image 106
blahdiblah Avatar answered Sep 30 '22 09:09

blahdiblah