Ultimate Guide to Manage Your iPod under Linux

I bought myself an iPod Nano (Product)red by the end of last year, it was cool. But the biggest problem i confront is how do i manage my iPod music library and sorts of things under Linux, since I’m a linux daily-user, i merely switch back to my Windows XP system. What’s more, i really DISLIKE using the iTunes under Windows, it’s just not so handy to me, as well it costs too much memory. So, with Google’s help, eventually i found some good solutions to make my iPod work under Linux. And here comes the guide, i’ll break it down into several sections, enjoy it!

Note: I’m using Gentoo linux, and KDE DE, but i presume things will be much even easier if you’re using the Everyone-Loves-It (k)ubuntu linux distro (I’ll make some notes below each paragraph, letting you ubuntu users know what to do)

Preparation

Before you get any further, first you need to install libgpod, that’s the core component to make iPod work under Linux. In Gentoo linux, you can simply run emerge libgpod, but please ensure that you’ve already added the gtk USE if you want to make the coverflow work, which i’ll explain later. So run USE="gtk" emerge libgpod is a good choice.

Note: What if you’re using (k)ubuntu? Dont worry about the Gentoo USE things, just run apt-install libgpod or some sort of that command (Sorry, I dont have ubuntu installed so i really have no idea the exact package name for libgpod)

To make my iPod automounted, i enabled hald and dbus service, and the KDE itself will handle the rest. Put the hal dbus into your make.conf‘s USE, and emerge the hal and dbus.

# echo "sys-apps/hal acpi disk-partition" >> /etc/portage/package.use
# emerge hal dbus

Then run emerge -auvDN world to make everything work with dbus and hal. Or you prefer using eix --installed-without-use hal and eix --installed-without-use dbus to manually check the packages which need re-emerge. After that, lets start ’em.

# /etc/init.d/dbus start
# /etc/init.d/hald start

if you prefer starting them when booting your system, just
# rc-update add dbus default
# rc-update add hald default

Note: The Ubuntu users can totally ignore what i mention above about the hal and dbus, since Ubuntu has already done these all for you, i said things will be much even easier :)

Music Library Management

This is the most important part, the software we need is Amarok, a multimedia killer app, which is also the best music player AFAIK. To make it work with iPod, lets first do the USE things :)

# echo "media-sound/amarok ipod" >> /etc/portage/package.use
# emerge amarok

1. Identify Your iPod

Once you get the hal work, the iPod device should be auto mounted (the default path is /media/ipod by udev rules), at least under KDE. Launch your amarok, and switch to the ‘Device’ tab, and identify your iPod model under ‘Set iPod Model’.

amarok-ipod-identifier

2. Transfer Music

Now you can easily ‘drag n’ drop’ your mp3s into the ‘Device’ tab container, or you can right click the files/albums/playlists to choose ‘Transfer to Media Device’

amarok-ipod-transfer1

amarok-ipod-transfer

The next step is simply click ‘transfer’, copy the mp3s into your iPod.

Note: It’s supposed to have your music appeared in your iPod if you installed >=libgpod-0.6.0. But what if your iPod (The Classic or Nano 3G, or iTouch) doesnt show any items you’ve transfered? Then we need to get our hands a little of dirty :)

Run lsusb -v | grep -i Serial with root privilege, and copy the 16-character-long hash string (something like 00A27001301221F) into the clipboard. Then open the /media/ipod/iPod_control/Device/SysInfo file with your favorite text editor, append this line into it:

FirewireGuid: 0xffffffffffffffff

Replace the ffffffffffffffff with that 16-character-long hash string you just got.

3. Cover Flow Effect

Coverflow effect is really fascinating, you can easily fetch the album art cover from Amazon via Amarok.

amarok-ipod-fetch-cover

To make sure your iPod recognize the coverart setting in Amarok, simply click the ‘Update Artwork’ under ‘Device’ tab, that’s all, i say THAT’S ALL :D

amarok-ipod-cover

Tip: If you have some V.A albums, you may find it quite disturbing when you flip the cover flow, seeing the same album image several times under different artist names. And they’re all pointed to the same album! To group ’em under Various Artists, just go to the Amarok’s ‘collection’ tab, right click the album and choose ‘Show under Various Artists’, then re-upload the album to your iPod. Or you can choose ‘Do not Show under Various Artists’ if you think the artist name does matter.

Video Management

With Amarok, you can also simply drag n’ drop the video files (mov, mp4) into your iPod, you dont need to worry about which directory they’re supposed to be placed.

So what i’d demonstrate here is how to convert the AVI movie file into your iPod MP4 file, and how to get the youtube video into your iPod.

1. Deal with AVI Movie File

What i want to deal with the avi movie file is to get a scaled clip video with only a few minutes which’s suitable for iPod playing, as well i’d also like to embed the subtitle into the clip due to my poor English understanding :D With Mplayer’s mencoder, everything turns out so easy.

Make sure you at least have these USEs enabled for mplayer. We need encode use to build mencoder support, and those vedio and audio libraries for encoding.

# USE="aac win32codecs xvid encode mp3 quicktime srt" emerge mplayer

Here is the command we’re gonna run: (based on bones7456’s nautilus toiPod script)

$ mencoder -ss 00:36:36 -endpos 00:01:35 \
   -of lavf -lavfopts format=mp4 -oac lavc -ovc lavc \
   -lavcopts aglobal=1:vglobal=1:vcodec=mpeg4:vbitrate=600:acodec=libfaac:abitrate=128 \
   -af lavcresample=24000 -vf dsize=320:240:0,scale=0:0,expand=320:240,harddup -ofps 25 -srate 22050 \
   -sub "subtitle.srt" \
   input.avi \
   -o output.mp4

Yeah, i know these commands seem too complex, let me break ’em down into detailed explanation.

  1. The -ss means the starting timeline, with-ss the -endpos means shifting forward time. In conjuction, this line -ss 00:36:36 -endpos 00:01:35 means we’re gonna start record the clip from 00:36:36 to 00:38:11 (36:36 + 01:35 = 38:11)
  2. The second, third and the fourth lines make sure the encoding meets the iPod spec requirement. If you have a larger screen like iTouch, iPod, change the 320:240 to 480:320.
  3. And we use -sub "subtitle.srt" to embed to subtitle into the clip
  4. The last line of the first command specifies the output filename

If you find the command too complex to recall, you can save the following script to /usr/bin/toIpod, and make sure it has the execute priviilege (chmod a+x /usr/bin/toIpod)

#!/bin/bash
#Copyright (c) 2008 bones7456 (bones7456<A>gmail<D>com)
#Modified by puNk!d
#License: GPL
#version 20080911

SAVEDIR="/home/media/video"

INFILE="$1"
PWD=`pwd`
CMD="mencoder -of lavf -lavfopts format=mp4 -oac lavc -ovc lavc "
CMD+="-lavcopts aglobal=1:vglobal=1:vcodec=mpeg4:vbitrate=600:acodec=libfaac:abitrate=128 "
CMD+="-af lavcresample=24000 -vf dsize=320:240:0,scale=0:0,expand=320:240,harddup -ofps 25 -srate 22050 "
if [[ -f "${INFILE%.*}.srt" ]];then
	CMD+=" -sub ""\"$PWD/${INFILE%.*}.srt\""
elif [[ -f "${INFILE%.*}.ssa" ]];then
	CMD+=" -sub ""\"$PWD/${INFILE%.*}.ssa\""
elif [[ -f "${INFILE%.*}.ass" ]];then
	CMD+=" -sub ""\"$PWD/${INFILE%.*}.ass\""
fi

CMD+=" -o ""\"$SAVEDIR/${INFILE%.*}_ipod.mp4\""" ""\"$PWD/$INFILE\""
eval "$CMD 2>&1"

Now you can run toIpod videofile to convert the video into mp4 file which is stored in /home/media/video, and it will automatically embed the subtitles if the sub file has the same name as the video file.

Note: The credit of this script goes to bones7456, I only did some small modification to deduct the gnome dependency (zenity tool).

2. Save Youtube Video into Your iPod

Here comes another scenario, I’d like to save the youtube video Tech Talk: Linus Torvalds on git into my iPod so i can watch it before sleep. We can achieve this with youtube-dl and FFmpeg. If you dont have ’em yet, just emerge ’em!

# emerge youtube-dl ffmpeg 

Make sure your ffmpeg compiled with at least aac, encode, win32codecs USEs.

Then we can obtain the youtube flv video file by:

$ youtube-dl "http://www.youtube.com/watch?v=4XpnKHJAok8" -o output.flv 

And use ffmpeg to convert it into mp4 file.

$ ffmpeg -i output.flv -acodec libfaac -ac 2 output.mp4 

Transfer the output.mp4 with Amarok, its done!

Note: As Michel pointed out, if you’re sick of the endless CLI, try Avidemux, a GUI tool does make life easier in some cases :D

Scrobble iPod Play History to Your Last.fm

badge_red

Amarok has last.fm built-in support, so whenever we play the music, the songs will be scrobbled to our last.fm account automatically. And the exciting thing is, Amarok can also handle iPod play history!

amarok-ipod-config

Just check the ‘Synchronize with Amarok statistics’ under ‘Configure Media Device’ dialog window. Then plug in your iPod, you can see the submit queue from Amarok status bar if there’re some tracks unscrobbled.

Transfer Photos into Your iPod

I use Gwenview as my first-choice photo management software on KDE, some of KDE users prefer Digikam. Whatever, it doesnt matter. Cuz they both support Kipi Plugins which we need to deal with iPod photo transfer.

Install Gwenview and Kipi-plugins with iPod support: (For ubuntu users, just get the gwenview and kipi!)

# USE="ipod" emerge libkipi kipi-plugins
# USE="kipi" emerge gwenview

gwenview-ipod-photo

Then we can see the ‘Export to iPod’ option under ‘Plugins’ -> ‘Tools’ menu in Gwenview.

Note: After some investigation and test, I found unfortunately there was no software perfectly delivered the photo transfer function. As kipi-plugin, libpod fails to show up the original picture on iPod whilst gpixpod produces a blank n’ black thumbnail. Read the discussion from here.

Note 2: As Thomas pointed out, there’s a patch for libgpod to fix the thumbnails problem. Follow the patch here: gtkpod with ipod nano 3g

Extras

Here comes the extra things part on iPod, we got Calendars, Contacts and Notes extras on iPod, but we dont feel like to deal ’em with iTunes. How come we need to do the simple note with a 50mb+ memory cost multimedia software :(

1. Notes

It’s quite easy actually, just put the text files into the /media/ipod/Notes directory, that’s ALL.

2. Calendar

iPod uses Mac’s iCal calendar file, but we dont have Mac, and neither we have iTunes. But we can use some third-party software like Ximian Evolution or Mozilla Sunbird under Linux, nonetheless, personally i’d like to use some web apps to deal with the iCal file. Google Calendar is definitely my 1st choice.

gcalender-ipod-setting

Choose one of your calendars, and click the ‘Calendar Settings’, in the bottom of the setting page, we see the iCal banner in ‘Private Address’, just save it to the /media/ipod/Calendars directory.

gcalender-ipod-ical

3. Contacts

iPod supports vCard to implement its Contacts function, and we can use Gmail to generate the vCard file
(C’mon, you should at least have a Gmail account unless you’re a Yahoo! die-hard fan :D )

I’m gonna save my words on howto do add contacts under Gmail, this is not the part of this iPod-related guide. To export the Gmail contact list into vCard file, click the ‘Contacts’ link in Gmail page, then choose to export it with vCard format, save it to your /media/ipod/Contacts directory.

gmail-ipod-contact

END

That’s all what i can tell you guys, if you have any other tips on iPod under Linux, feel free to share with us.

And, i know there’s a software named gtkpod which can deals with iPod media synchronizing and photo transfer. But i dont feel like to recommend it, IMHO, its just not so handy as Amarok and Gwenview. Anyway, you might prefer using it if you’re using Gnome :)

3 Reponses So Far ↓

  1. Donald:

    I’ve got a new question…
    I’ve converted three films (avi) with your script, but the image is really really small… In the center of the screen, I think, 2 cm on 4…
    My Ipod is the Classic one, 120GB 5th generation. Do you have any idea about the properties of convertion?
    Thanks again

  2. Donald:

    Sorry about that!

    So, its in the CMD+ lines.

    Properties of my ipod:

    MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats

  3. Just change the 320:240 to 640:480 inside the script. (note: there’re two 320:240s you need to modify)

Leave a Reply ↓