Saturday, March 22, 2008

iPod video for Linux

Google will tell you that you can convert video to iPod format in Linux using only VLC. When lots of people tell you something on the Internet, and post howtos, this is often a good sign that lots of people on the Internet are idiots. This is one of those times. None of the howtos worked; I was getting either a corrupt file or no audio. I am clearly not the only one, because every single howto I found that explained how to use VLC to transcode video, and there are quite a few, ALSO had commenters saying "um, the audio doesn't work".

I finally discovered a solution, though, so it's sharing time. Note that this is probably unnecessary if you just want to watch video podcasts, because gpodder works fine for that. For non-podcast video, you almost always need to do a conversion.

(Using Ubuntu, version HammurabiHardy Heron.)

For this meal, you will need these ingredients (aptitude install ..):

avidemux
avidemux-cli
vlc
faad
faac
(every gstreamer plugins package you can find in main or in universe / multiverse)
gtkpod-aac

The avidemux-cli package is optional; handy if you want to convert a whole directory full of files. Note that you are going to install vlc, because it is one of the few players that will reliably play back these files. You want it so you can test your output files before installing them on your ipod, but it may be considered optional.
  1. Open up the avidemux GUI, and open the file you want to convert.
  2. Select menu item Auto > IPOD
  3. Confirm that video is being encoded with XVID4. Optionally change the video bitrate to 1024 through the Configure button.
  4. Audio encoding will still show "Copy". Change it to "AAC". Confirm through the configure button that the bitrate is 128.
  5. Confirm that Format is MP4.
  6. Save. Encoding will begin.
Optional: Batch Conversion. When done, you may save this as a script with "File > Save Project As ..." which allows you to do this from the command line. However, I have already done the work for you. To run it from the command line, get the shell script and .js file from http://wiki.goonmill.org/AvidemuxScript. If you save the shell script as "mp4", you can run it in a directory of AVI files, as

mp4 *.avi

Test the converted file in VLC, making sure video isn't crappy and audio exists.

Now copy it to the iPod. You need gtkpod-aac installed for this, or you will get errors saying "compile gtkpod together with yadda yadda". The package gtkpod-aac contains a binary that is already so compiled. You can simply plug in the iPod, choose your model from the supported list in gtkpod, find the iPod in the tree at the left, pick "video inbox", and Add File there to add your file. Save to copy to the ipod, and Eject the ipod.

2 comments:

Anonymous said...

I must say, do NOT use the xvid codec. With my experience, it really sucks. Using all default settings, I could easily identify keyframes. Increasing the bitrate to 1024 I still could tell where the keyframes were.

Instead you should use h264. (x264 is the open source encoder.) The script you made is easily modifiable for this. With h264, the video is smooth and doesn't look encoded. Keyframes are not identifiable to me.

In my experience, a setting of 8 for the quantizer is good enough. (The encoder doesn't take a bitrate parameter.)

Also, in your scripts, you have the framerate explicitly specified. This caused errors on my end. I commented it out and things worked fine.

Finally, I cannot comment on how to install things with Ubuntu, but using Gentoo, mplayer can be compiled with aac support, and is much better than vlc, in my opinion.

avi to ipod said...

I have been looking for this information for over an hour now. I am trying to find info about iPod videos for Linux. I am so thankful that I found this post.