Gregory Hildstrom Projects Publications Resume Links Contact About Google+ Facebook Youtube Donate



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.6i has not worked in my testing, but MPEG4 video does. The H.264 codec from VLC 1.1.7 works, but the video can be a bit jumpy when played back on Apple devices. 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 with 0.8.6i, but specifying width=640 in 1.1.7 works great. 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 drag&drop a video file onto this batch file

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

@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

@rem for vlc-0.8.6i
@rem %vlc% -vvv %1 :sout="#transcode{vcodec=mp4v,vb=1024,scale=0.88,acodec=mp4a,ab=160,channels=2,samplerate=44100}:duplicate{dst=std{access=file,mux=mp4,dst=%output%}}"
@rem for vlc-1.1.7
%vlc% -vvv %1 :sout="#transcode{vcodec=h264,vb=1024,width=640,acodec=mp4a,ab=160,channels=2,samplerate=44100}:duplicate{dst=std{access=file,mux=mp4,dst=%output%}}"
: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 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 for vlc-0.8.6i
@rem %vlc% -vvv "dvdsimple://%dvddrive%" :sout="#transcode{vcodec=mp4v,vb=1024,scale=0.88,acodec=mp4a,ab=160,channels=2,samplerate=44100}:duplicate{dst=std{access=file,mux=mp4,dst=%output%}}" vlc:quit
@rem for vlc-1.1.7
@rem %vlc% -vvv "dvdsimple://%dvddrive%" :sout="#transcode{vcodec=h264,vb=1024,width=640,acodec=mp4a,ab=160,channels=2,samplerate=44100}:duplicate{dst=std{access=file,mux=mp4,dst=%output%}}" vlc:quit
@rem for vlc-1.1.7 with subtitles
%vlc% -vvv "dvdsimple://%dvddrive%" --sub-language En :sout="#transcode{vcodec=h264,vb=1024,width=640,acodec=mp4a,ab=160,channels=2,samplerate=44100,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.