Difference between revisions of "IPod Video Conversion Guide"

From VideoLAN Wiki
Jump to navigation Jump to search
(Edited by Amun-Ra of http://illusiononline.net with batch source code.)
Line 76: Line 76:
 
'''NOTE:''' If you can somehow to get 264 to work (megui makes it work...) just change ''vcodec=mp4v'' to ''vcodec=h264''.  
 
'''NOTE:''' If you can somehow to get 264 to work (megui makes it work...) just change ''vcodec=mp4v'' to ''vcodec=h264''.  
  
 
+
The script to drag and drop files (for Windows) is as follows:
 +
<code>
 +
C:\PROGRA~1\VIDEOLAN\VLC\VLC -vvv %1 :sout=#transcode{vcodec=mp4v,vb=512,acodec=mp4a,ab=128,channels=2,width=320,height=240}:duplicate{dst=std{access=file,mux=mp4,dst=%1.m4p}}
 +
pause
 +
</code>
 +
There is no problem with spaces in filenames.
  
 
''This is also described (with snapshots) on http://tom.zickel.org/vlcmp4/''
 
''This is also described (with snapshots) on http://tom.zickel.org/vlcmp4/''

Revision as of 01:23, 22 February 2007

This page describes how to make your Video Files playable on an iPod. Other "how to" pages

To play on this device, the file you copy to it needs to be of the correct format. This format is summarized below:

Video Codec mp4v (MPEG4)
Audio Codec mp4a (MP4 audio), aac (AAC)
Container mp4 (MPEG4/MOV)
Size 320x240

To make the video the correct size, you can edit the preferences, or run vlc from a command prompt.

vlc "input_filename" :sout="#transcode{vcodec=mp4v, vb=512, acodec=mp4a, ab=128, channels=2, audio-sync, width=320, height=240}:std{access=file, mux=mp4,url="output_filename"}" --aspect-ratio=width:height

This all goes on one line, and you'll need to fill in some of the values: the input and output filenames, plus the aspect ratio of the input file. By default vlc will stretch the video to the size specified by sout-transcode-height and width, but if you tell vlc the file's aspect ratio, it will scale and put a black border around it. The aspect ratio can be written as a ratio of width and height, with a colon between the two, or as a decimal.

Further I found that the iPod was particular about the parameter "channels" being set to 2. I found that without this parameter iTunes would import the file into the library but would not be able to upload the same to the iPod.

Further during my experiments I figured out that it was better to stick with MPEG4 encoding for the video stream. While H.264 codec is the latest video compression standard I found the resultant file size usually larger than when the MPEG4 compression mode was used, keeping all the other parameters like the resolution and the bitrate same. This definitely seems contradictory to what I would have expected but these were the findings of my experiments while using videoLan VLC media player.

(In fact, if the bit rates are chosen equally, the file sizes can be expected to be roughly the same. The advantage of h.264 over mpeg4 is its better video quality with the same bit rate or the allowance for lower bit rates and thus smaller files with comparable video quality.)

If you would like to try using H.264 set the parameter vcodec to h264 in the above command line as follows

vlc "input_filename" :sout="#transcode{vcodec=h264, vb=512, acodec=mp4a, ab=128, channels=2, audio-sync, width=320, height=240}:std{access=file, mux=mp4,url="output_filename"}"--aspect-ratio=width:height

A useful tip - If you intend to create a batch file that would transcode several titles in a DVD one after the other use the keyword vlc:quit as follows

vlc "input_filename" :sout="#transcode{vcodec=h264, vb=512, acodec=mp4a, ab=128, channels=2, audio-sync, width=320, height=240}:std{access=file, mux=mp4,url="output_filename"}" vlc:quit --aspect-ratio=width:height

Converting Oddly Sized Input Videos to View on the iPod Video

The command-line examples above did not work for me when converting video that did not already have a 4:3 aspect ratio. After converting the video, iTunes would not load the video into my library, and I would get "invalid data" errors when trying to view the file in the Quicktime Player. It seams as of at least version 8.6a (not tested on previous versions), vlc will use just the height value to determine the resultant width, while maintaining the original aspect ratio, not the specified ratio.

To remedy this, I used the sout-transcode-canvas-height option with the sout-transcode-width and removed the specific aspect ratio option and the specific height declaration. My example command-line is below:

vlc.exe -vvv "my video.avi" :sout="#transcode{vcodec=mp4v, vb=768, acodec=mp4a, ab=96, channels=2, samplerate=22050, width=320, canvas-height=240} :standard{access=file, mux=mp4, url=my video.mp4}" vlc:quit

NOTE I've noticed that some files encoded with XVID come out without video. If this happens, try using vcodec=h264.

This command will start vlc, transcode the video to file, and quit when complete. The resultant video will be 320x240 with a black canvas filling in the height to the video borders. If the input is already has a 4:3 (320x240) aspect ratio, then no border will appear.

Here is an iPod format sample video converted with vlc.

Using Batch Files

Here is the info for a batch file to convert videos one after another, although you have to enter your input and output values yourself (use find and replace, or, if you are better than me, make an actual script/program). Make sure the output names are different or else it will get stuck and/or overwrite the old one

vlc "input_filename" :sout="#transcode{vcodec=mp4v, vb=512, acodec=mp4a, ab=128, channels=2, audio-sync, width=320, height=240}:std{access=file, mux=mp4,url="output_filename"}" vlc:quit --aspect-ratio=width:height

vlc "input_filename(1)" :sout="#transcode{vcodec=mp4v, vb=512, acodec=mp4a, ab=128, channels=2, audio-sync, width=320, height=240}:std{access=file, mux=mp4,url="output_filename(1)"}" vlc:quit --aspect-ratio=width:height

......etc for each video to convert (useful for converting short .flv or .gvi, or pretty much any file) I relise this is inefficient,

but hopefully someone will make a script (vlc seems best for making ipod videos from any source). NOTE2: I find that if i have spaces in the output it doesn't work, but this seems to be a problem with the .bat file. just don't use spaces and use an autorenamer to rename ([1]) NOTE: If you can somehow to get 264 to work (megui makes it work...) just change vcodec=mp4v to vcodec=h264.

The script to drag and drop files (for Windows) is as follows: C:\PROGRA~1\VIDEOLAN\VLC\VLC -vvv %1 :sout=#transcode{vcodec=mp4v,vb=512,acodec=mp4a,ab=128,channels=2,width=320,height=240}:duplicate{dst=std{access=file,mux=mp4,dst=%1.m4p}} pause There is no problem with spaces in filenames.

This is also described (with snapshots) on http://tom.zickel.org/vlcmp4/


This has also been discussed in the forum


I followed these steps and was able to watch and listen on the ipod. The recorded audio level was pretty low, is there a way to make the audio louder in output_filename ?