Thursday, September 03, 2009

Embbed cover art in MP3 files with command line

Introduction

I needed a command line (cli) application that would allow me to embed cover art to my MP3 collection in order to get the covers diplay correctly in my wife's iPhone and my own gPhone (HTC-Hero). After looking around I finally found the ideal tool: eyed3.

Embedding cover art in MP3 files

In Ubuntu/Kubuntu install ImageMagick and Eyed3 with the following command:

then you can use these tools to embed the image in the MP3 files:

The first command uses ImageMagick to resize the image if any dimension is larger than 300px and the second command adds the cover art to all the MP3 files present in the current directory.

Note that the cover image is called AlbumArt.jpg and that the resize operation overwrites it. If you prefer to keep the original change the name of the output to something else. Also you can embed more than one image to each MP3 and assign it different types like FRONT_COVER, BACK_COVER, MEDIA, etc. Check eyeD3 help for more information.

The embedded cover art will display correctly in iTunes, iPhone and Android without problems.

Android cover art for Ogg/Vorbis and MP3 files


All my Japanese music is in Ogg/Vorbis format mostly because MP3 players cannot agree in the metadata encoding for Japanese characters. Each MP3 player I have tried (including Amarok) use a custom (i.e. no standard) way to save non ASCII characters making it impossible to display Japanese correctly in all devices/players I own.

In the other hand Ogg/Vorbis displays the Japanese correctly in all players I use (Amarok/gPhone/ffmpeg/mplayer) but it does not support embedded cover art. Fortunately in Android phones if there is a file named AlbumArt.jpg the same folder the Ogg/Vorbis file is located then it will use that file as cover art.

With this layout both Amarok and my Android Phone display the AlbumArt.jpg for all the ogg/mp3 files contained inside the same folder.