Showing posts with label Gadget. Show all posts
Showing posts with label Gadget. Show all posts

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.

Monday, March 26, 2007

Sony NW-A808 PMP Linux review



I recently got this little piece of hardware and I really like it. It supports video, audio and images in a very small and stylish pack. I was deciding between the NW-A808 and the iRiver X20 but finally decided to go with the NW-A808 mostly for the cool factor. The iRiver X20 is bigger and has a plastic case that makes it feel like a toy. The NW-A808 has a very slim and metallic case (iPod like) that feels just right on my hand. Also the NW-A808 has a nice variety of colours to choose while the X20 comes only with a black version.

The NW-A808 GUI supports various languages so I can set it up in English or Spanish if I want instead of the default Japanese. It supports album covers, video thumbnails and has a lot of play list features like search, bookmarks, and much more.

The good and the bad

The good thing is that this device supports MSC (aka UMS) that is very well supported by Linux. Plugging the player to my laptop running Kubuntu Feisty I get a pop-up window asking me if I want to open it in a new window.

Opening the device (/media/WALKMAN) in Konqueror shows me the content of the device and I can easily copy/delete files into it. It is possible to add images and videos to the device by directly copying them into the flash memory.

The bad thing is that first: it does not support Ogg and second: that to add music files to the device we are forced to use a crappy piece of proprietary software called Sonic Stage on Windows. I haven't found yet any Linux alternatives to replace Sonic Stage but rest assured that someone (maybe me), someday (far in the future) will take the task to make this device Linux friendly.

Uploading Images

To upload your images to the NW-A808 flash memory you MUST create sub folders inside the DCIM directory that is in the flash memory and copy your images inside those sub folders. You can copy them directly inside the DCIM folder but they will not get listed on the device library browser.

From the instruction manual the images format supported is:

  • File Format: DCF 2.0/Exif 2.21

  • Extension: .jpg

  • Codec: JPEG(Baseline)

  • Max Resolution: 4,000x4,000 (16 Megapixels)

  • Quantity: Maximum 10,000 files



Uploading Videos

As with the photos we only need to copy our video files in mp4 format inside the VIDEO folder that is inside the device flash memory. Pay attention to the supported video format as any file not supported may be listed in the video library but the player will refuse to play it.


  • File Format: MP4

  • Extension: .mp4, .m4v

  • Video Codecs:

    • MPEG-4

      • Profile: Simple Profile

      • Max bitrate: 2,500 kbps

      • Max fps: 30 fps

      • Max resolution : 320x240(QVGA)



    • AVC (H.264/AVC)

      • Profile: Baseline Profile level 1.2 and 1.3

      • Max bitrate: 768 kbps

      • Max fps: 30 fps

      • Max resolution : 320x240(QVGA)





  • Audio Codecs: AAC-LC

    • Number of Channels: 2

    • Samplig rates: 24, 32, 44.1 and 48 kHz

    • Bitrate: 288kbps per channel





Based on the video/audio specifications above we can use the all mighty ffmpeg to convert almost any video to a format that can be played on the device:
Since this is a device created by Sony I concluded it supports the same video format the PSP does . A simple Google search for "mencoder PSP" led me to this post with the following command:

ffmpeg -y -i $infile -vcodec libx264 -b 768k -bt 768k -level 13 \
-r 30 -croptop auto -cropbottom auto -s 320x240 -acodec libfaac \
-ar 48000 -ab 100k -ac 2 -f mp4 $outfile.mp4

With this command I was able to convert most of my mpg and avi files to mp4 and play them in the NW-A808. Once you transcode you videos copy them to the Videos directory inside the device flash and they will be listed on the video library.

There is a little functionality drawback if we copy files directly to the flash. The NW-A808 displays the video file name and a nice THM thumbnail in the video browser when the files are copied using Sony's proprietary software. I have tried in several ways to create the thumbnail file manually without success so far.

Filenames and Folders



It is possible to copy images and videos in any folder inside the device flash. It is also possible to create sub folders in any place and put files inside those sub folders. But only the images and videos that are inside the DCIM and VIDEO folders respectively will get listed on the device browser. See the image above to get an idea of the folder layout.

You can copy all video files directly inside the VIDEO folder in flash or create sub folders (one level deep only) and put the video files on those sub folders.

For images you cannot directly put the files inside the DCIM directory. You must create sub folders (one level deep) inside the DCIM folder and copy the images inside those sub folders.

Also make sure the extensions are jpg for images and mp4/m4v for video or the player won't list them.

Uploading Audio Files

Now the biggest drawback of this and all other Network Walkman devices produced by Sony. To upload music files we must use Sonic Stage on windows because simply copying the music files on the device won't list them on the album browser.

So far the closest I have found to make this device work on Linux is the libnw library created by Waider. Too bad this library does not work on my device but Waider has shown interest in modifying his library to support the NW-A808. Once libnw supports this device it won't be difficult to write an Amarok MediaDevice interface to manage it.

Sony uses GPL software?

Not really sure why but inside the NW-A808 box came a copy of the GPLv2 licence. It means (maybe?) that the software provided by Sony to handle the deviceuses some GPLed software/libraries.

I am no lawyer but as I understand if this is true then isn't Sony supposed to release the source code of such applications?. With a source code it would be easier to implement a Linux alternative to make these devices more Linux friendly.