Wednesday, December 06, 2006

Convert RMVB to iPod Video

As I started my quest to put RMVB videos to my newly acquired video ipod, I realized that ffmpeg simply does not have the codecs to decode this RMVB format. I kept googling the potential candidates but most of the solutions I found are non-free/commercial software. Finally, I took a chance with mencoder and had some success. It's not a smooth sail using mencoder. I tried it first on my 64 bit AMD linux machine, and none of the realvideo codecs worked. Therefore, I have to do it on my windows machine :-( Followings are the steps to successfully converting the RMVB:
  1. Download MPlayer 1.0rc1 Windows and grab "windows-all-20061022.zip" from codecs directory.
  2. Unzip both of them into the same directory. Let's say, C:\mplayer.
  3. Assume you want to convert "Cars.rmvb" and it is in "C:\Documents and Settings\All Users\Documents\". Open Notepad to type the following textbox as a single line and save the file as "encode.bat".
  4. Double click "encode.bat" to execute it. "Cars.mp4" will be created. Use iTune or gtkpod (on your linux machine) to transfer the mp4 into ipod :-)

"encode.bat"

The first thing we should keep in mind is the video ipod limitation. From ipod specs, we can immediately learn that the allowed video formats are H.264 and MPEG-4, and the allowed audio codec is AAC. For MPEG-4, the pixel limit is 640x480 and the max. frame rate is 30 fps. As a result, "vcodec=mpeg4" and "acodec=aac" are used.

Of course, we also need to understand the command line of mencoder to successfully convert every given RMVB file. The listed command line in "encode.bat" is very similar to Encoding to Sony PSP video format from the mencoder documentation. We'd better have this documentation ready to explain every parameter that can be used.

Another crucial element is understanding the video source - video bit rate, fps, and aspect ratio. Read video info using either Real Player or Real Alternative. For example, the source Cars.rmvb has these properties

  • Avg Stream Bit Rate: 996.9 Kbps
  • Dimensions: 800x452
  • Encoded Frame Rate: 24.0 fps
Therefore, I use
  • vbitrate=800 to sacrifice a little bit quality to control the output file size, I certainly don't think there is any benefit to use bit rate larger than 996.9 Kbps.
  • -ofps 24.0 to match the output frame rate. Otherwise, mencoder will keep complaining skipped frames.
  • -vf scale=640:362 to keep the correct aspect ratio and shrink the pixel size (remember the ipod limitation).

No comments:

Skiing at Winter Park