Friday, December 31, 2010

Uploading a video to an iPod Nano 3rd generation

I needed a GUI to upload a few videos to an iPod nano from my machine running Ubuntu Lucid. I thought things would have been smoother than they were a few years ago when I last tried doing this. But I was wrong...  I tried Arista and Transmageddon, but you have to manually select files one by one. Even though both of these do the job perfectly, I have 50 files I need to upload and just want to select all of them at once. So, this is what I came up with. Two things need to be done in order to transfer a video file from a computer to an iPod:
  • First, the video must be encoded in a format recognised by the iPod.
  • Second, the encoded video can then be transferred to the iPod.

Video encoding

To encode the video, I used the excellent cross-platform ffmpeg GUI WinFF . But first, we need to make sure ffmpeg knows how to encode AAC. For that, we need to add the MediBuntu repository, and update libavcodec and ffmpeg:

sudo wget http://www.medibuntu.org/sources.list.d/`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get -q update && sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring && sudo apt-get -q update

This adds the MediBuntu repository and its key.

Next, update ffmpeg and install WinFF.

sudo apt-get install ffmpeg libavcodec-extra-52 winff


WinFF comes with many presets so you can convert for a specific device with just a few clicks, and not having to worry about ffmpeg command line arguments. However, in the WinFF version that comes with Ubuntu Lucid (v1.2), I tried all the iPod presets, but none produced a video file that could be read by my iPod (the video was always black). After googling around to find out what format I should be using, I figured encoding the video in mpeg4 and audio in AAC did the trick. So the next step is to create a WinFF preset:
In WinFF, click Edit -> Presets. Then in the Edit Presets dialog, enter the following
  • 'IPODNANO3G' as the preset name,
  • 'iPod Nano 3G Video fullscreen' as the label
  • '-acodec libfaac -ab 128kb -ar 44100 -vcodec mpeg4 -s 320x240 -b 400kb -strict -1 -r 25' as the preset command line,
  • 'm4v' as the extension,
  • 'RockBox' as the category
Click Add/Update and then save. If it all goes well, back in the main window, select RockBox in the 'Convert To ...' dropdown menu, and you should be able to select 'iPod Nano 3G Video fullscreen' in the 'Device Preset' dropdown menu.

You can now transcode your existing videos into a format which the iPod nano can play, by adding all the files to be converted, selecting the above preset and clicking 'Convert'.



Video uploading
This is the easy part. I used gtkpok for that.

sudo apt-get install gtkpod-aac libmp4v2-0

Next connect your iPod (make sure it is mounted) and run gtkpod. Select your iPod and click 'Add files'. Select your transcoded-video files (with a .m4v extension), and click 'Save changes'.
Done

No comments:

Post a Comment