Hildstrom Engineering Projects Publications Resume Links Contact About Home Flickr Youtube

Convert Videos and DVDs to iPod/iPhone Format Using VLC

Anything that VLC media player can play, it can transcode to another container or codec. This is true of individual media files and whole media discs; you just have to get the input file or device right and only certain codecs work within certain containers.

To prevent iTunes from trying to further transcode and convert your video, iPod and iPhone videos must be in an mp4 container, with either MPEG4 or H.264 video codec, and AAC/MPEG4 audio codec. However, H.264 from VLC 0.8.6h has not worked in my testing, which leaves us with MPEG4 video. The iPod Classic has a maximum video file resolution of 640x480 pixels, so set the scale so the resulting video will fit within this resolution. This is not the same as the iPod Classic's screen resolution of 320x240. For example, an input video that is 720x480 needs to be scaled down: 640/720=0.88888. I used scale=0.88 to be on the safe side. Do not worry about scaling directly to the iPod or iPhone's screen size because it can handle that during playback. Also, reducing the video bitrate effectively reduces resolution when necessary, so a higher resolution will pay off during certain scenes when played back on a computer or higher-resolution device. The video bit rate needs to be under 2.5Mbps and the audio bit rate needs to be under 160Kbps according to the iPod Classic's specifications. I chose to max out the audio bit rate and use 1024Kbps for video, which looks stellar on small devices and decent on computers.

Let's say you have an avi, asf, mov, rm, or flv file that plays in VLC, but iTunes says the files cannot be played by your iPod or converted. You could use the VLC wizard to convert a single video file, but that gets old quick if you have more than one file to convert. Many commercial products exist, but they cost money.

My solution is a Windows batch file that accepts a single file dragged onto it: 2ipod-from-vid.bat

@rem just drag a vlc-compatible media file onto this batch file
@rem it has been tested with .vob, .avi, .asf, and .mpg files,
@rem but it should work with anything that VLC can play

@rem check for an input file
@if %1 == "" goto end

@rem argument 0 is the batch file itself
@rem 1 would be the first argument to the batch file
@rem the at symbol means do not echo the command
@rem the entire argument 1 can be referenced with %1
@rem this section is to place output in the same folder as the argument 1 file
@set drive=%~d1
@set directory=%~p1
@set filename=%~n1
@set extension=%~x1
@%drive%
@cd %directory%

@rem this is the output file
@set output=%drive%%directory%%filename%.mp4

@rem check if the output file exists
@if exist %output% echo The output file already exists
@if exist %output% pause
@if exist %output% exit

@rem this variable must be changed
@set vlc="C:\Program Files\VideoLAN\VLC\vlc.exe"

@rem --start-time=10 skips the first 10 seconds of the input video
@rem --stop-time=X stops at the specified time instead of the end of the file
%vlc% -vvv %1 :sout="#transcode{vcodec=mp4v,vb=1024,scale=0.88,acodec=mp4a,ab=160,channels=2}:duplicate{dst=std{access=file,mux=mp4,dst=%output%}}" vlc:quit
:end
pause



Now let's say you own a DVD that plays in VLC, but you want to watch it during a flight on your iPod or iPhone. You could use the VLC wizard to convert a single DVD, but that gets old quick if you have more than one DVD to convert. Many commercial products exist, but they cost money.

My solution is a Windows batch file: 2ipod-from-dvd.bat

@rem this batch file accepts no arguments, so just double-click it
@rem it should work with any DVD that VLC can play

@rem argument 0 is the batch file itself
@rem 1 would be the first argument to the batch file
@rem the at symbol means do not echo the command
@rem the entire argument 1 can be referenced with %1
@rem this section is to place output in the same folder as the batch file
@set drive=%~d0
@set directory=%~p0
@set filename=%~n0
@set extension=%~x0
@%drive%
@cd %directory%

@rem this is the output file
@set output=%drive%%directory%%filename%.mp4

@rem check if the output file exists
@if exist %output% echo The output file already exists
@if exist %output% pause
@if exist %output% exit

@rem these two variables must be changed
@rem use d:@1:2 to start with title 1 chapter 2
@set vlc="C:\Program Files\VideoLAN\VLC\vlc.exe"
@set dvddrive=d:

@rem replace scale=0.88 with width=640, height=480 to force an output resolution
%vlc% -vvv "dvdsimple://%dvddrive%" :sout="#transcode{vcodec=mp4v,vb=1024,scale=0.88,acodec=mp4a,ab=160,channels=2}:duplicate{dst=std{access=file,mux=mp4,dst=%output%}}" vlc:quit
@rem or use this command version instead to overlay subtitles in the video
@rem if necessary --sub-track 0 will force a specific subtitle track
@rem %vlc% -vvv "dvdsimple://%dvddrive%" --sub-language En :sout="#transcode{vcodec=mp4v,vb=1024,scale=0.88,acodec=mp4a,ab=160,channels=2,soverlay}:duplicate{dst=std{access=file,mux=mp4,dst=%output%}}" vlc:quit

pause



I have converted many video files with these batch files and the resulting .mp4 files play great in VLC, iTunes, Quicktime, iPod Classic, iPod Touch, and iPhone 3G.