Howto encode DVD video for an iPod (ffmpeg)

By thomas, 7 March, 2006
My co-worker just got an iPod so I thought I would try and encode a DVD onto it (an unencrypted DVD that I own, for backup purposes only, not to be used for public performances, etc, only I looked at it, I shut it off when someone looked over my shoulder...blah blah). The ffmpeg that comes stock on RHEL4 is insufficient to do the transcoding. I built a newer version and mucked around a bit and got this going. I have a simple wrapper (there are numerous versions of such scripts floating around).

ffmpeg-20060306 RPM SRPM SPEC

Find your VOB files on the DVD
[uphill@burnaby ]$ mount /dev/dvd [uphill@burnaby ]$ cd /media/cdrecorder/VIDEO_TS [uphill@burnaby ]$ ls *VOB [uphill@burnaby VIDEO_TS]$ ls *VOB VIDEO_TS.VOB VTS_03_0.VOB VTS_06_0.VOB VTS_09_0.VOB VTS_12_0.VOB VTS_01_0.VOB VTS_03_1.VOB VTS_06_1.VOB VTS_09_1.VOB VTS_12_1.VOB VTS_01_1.VOB VTS_04_0.VOB VTS_07_0.VOB VTS_10_0.VOB VTS_01_2.VOB VTS_04_1.VOB VTS_07_1.VOB VTS_10_1.VOB VTS_02_0.VOB VTS_05_0.VOB VTS_08_0.VOB VTS_11_0.VOB VTS_02_1.VOB VTS_05_1.VOB VTS_08_1.VOB VTS_11_1.VOB Then run ffmpeg on them to encode them for the iPod (this is for a 4:3 format file) [uphill@burnaby VIDEO_TS]$ ffmpeg \ -i VTS_01.VOB \ # input file name -f mp4 \ # output file format -r 30 \ # frame rate -vcodec mpeg4 \ # video codec -maxrate 1000 \ # maximum video bitrate tolerance -b 700 \ # video bitrate in kbit/s -qmin 3 \ # minimum video quantiser scale (VBR) -qmax 5 \ # maximum video quantiser scale (VBR) -bufsize 4096 \ # rate control buffer size -g 300 \ # gop (group of pictures) size -acodec aac \ # audio codec to use -ar 44100 \ # audio sampling frequency -ab 192 \ # audio bitrate -s 320x240 \ # output resolution -aspect 4:3 \ # aspect ratio /tmp/output.mp4 # filename for output Your output file should then be able to transfer the file to your iPod and enjoy. The VOB files on the DVD are not likely to be split up exactly as you would like to have them. To get the whole movie off the dvd, you'll need to feed all the VOB's into ffmpeg, note that the menu's are also stored in a VOB file, so you'll want to figure out which ones those are and not include them.

For example, the menu's on my DVD are in VTS_01_0.VOB, so I did the following: [uphill@burnaby VIDEO_TS]$ for vob in `ls *VOB |egrep -v VIDEO\|01_0`; do echo -n "$vob "; done; echo VTS_01_1.VOB VTS_01_2.VOB VTS_02_0.VOB VTS_02_1.VOB VTS_03_0.VOB VTS_03_1.VOB VTS_04_0.VOB VTS_04_1.VOB VTS_05_0.VOB VTS_05_1.VOB VTS_06_0.VOB VTS_06_1.VOB VTS_07_0.VOB VTS_07_1.VOB VTS_08_0.VOB VTS_08_1.VOB VTS_09_0.VOB VTS_09_1.VOB VTS_10_0.VOB VTS_10_1.VOB VTS_11_0.VOB VTS_11_1.VOB VTS_12_0.VOB VTS_12_1.VOB [uphill@burnaby VIDEO_TS]$ Then I simply pasted this output into my ffmpeg line above.

[uphill@burnaby VIDEO_TS] cat VTS_01_1.VOB VTS_01_2.VOB VTS_02_0.VOB VTS_02_1.VOB VTS_03_0.VOB VTS_03_1.VOB VTS_04_0.VOB VTS_04_1.VOB VTS_05_0.VOB VTS_05_1.VOB VTS_06_0.VOB VTS_06_1.VOB VTS_07_0.VOB VTS_07_1.VOB VTS_08_0.VOB VTS_08_1.VOB VTS_09_0.VOB VTS_09_1.VOB VTS_10_0.VOB VTS_10_1.VOB VTS_11_0.VOB VTS_11_1.VOB VTS_12_0.VOB VTS_12_1.VOB | ffmpeg -i - \ #the rest of the options... I still need to play a bit with the settings, I optimised for quality, I need to have a low quality setting also. I will probably built yet another wrapper for all this too, why not, everyone else is :-D