How To Convert iPod Video to Divx or Other Formats
I'm into podcasts both audio and video. Except for live things like baseball games I rarely even listen to the radio in my car any more.
One of the things that I don't like is that most podcasters encode their video for the iPod. I don't blame them. The iPod is the market leader and bandwidth and time are limited. Unfortunately we don't have a video standard as ubiquitous as the mp3 file.
Thing is, I don't own an iPod. Audio or Video. I do own the remarkable Archos Gmini 402. The 402 plays Divx compatible files and wmv files. That doesn't do you much good in a video podcast world full of mov, m4v and mp4 files. Then there is the fact the some people like to encode to different screen resolutions and sizes. Some do 16:9 and some do 4:3. It's a whirlwind of file types and variables.
What I'm going to show you is how I take all those files and convert them to a format compatible with my player. I've been using this for a month or 2 now and have been tweaking the settings. This technique should work for any player that plays divx including the psp.
I chose divx compatible because it works in my player and other devices I have like my stand alone Divx-playing DVD player. With a bit of tweaking you can get it to encode to other formats as will.
The instructions are for Windows. The tools have versions available for other platforms such as Linux so if you are savvy enough to convert the batch file I'm going to tell you about you should be able to use it on those systems as well.
I'm going to assume you know how to acquire video podcasts. Actually, even if you just go to sites and download the files by hand and put them in the appropriate folder you'll be able to use this technique as well. I'll list a few of my favorite video podcasts at the end of this post.
Tools
To work this magic you need 3 tools. They're all open source and free.
- mencoder - This is the brilliant software that does the encoding. As of this writing, MPlayer-mingw32-1.0rc1 is the latest for Windows. Mencoder comes as part of MPlayer
- xvid codec - You'll want to make sure this is on your PC so you can play the files you create
- My batch file - Described below
I chose to use a batch file because once you figure out how these things work you can easily tweak it. I also like to call the batch file from the task manager so I can use the power of the PC during the early hours of the morning to have everything waiting for me later on.
Additional Documents
If you get into this you might want to refer to these documents.
- HOWTO Mencoder Introduction Guide - Nice overview on how to use Mencoder
- MPlayer - The Movie Player - The most up to date man page (aka help file) for MPlayer/Mencoder
- Batch File Command Reference for Windows 2000 - Suitable for Windows 2000 and beyond. Nice tidbits on all the obscure commands you never new about or forgot.
The Magic Batch File
Below is the text of the batch file. You might want to download it instead of copy/paste in case of line wrap issues. I tried to comment it as much as I could to help explain the options you need to set. You can't just run it. You need to set up the directories you have and make decisions on the options I mention as you read through it. Fortunately you only need to do this once.
Once set up properly, when run, the batch file will check all the directory and subdirectories you indicate and process any video file (.mp4 or .m4v or .mov or .mpg or .wmv). Yes, even wmv. I do that because people who encode to wmv sometimes like to make these huge files that don't always play well on portable devices.
One of the problems with video is that everyone likes to create their content in different sizes. While most video podcasts are 320:240 some can be bigger and some can be wider. Your screen is only designed for a certain maximum. If you look closely at the batch file it scales to 320:-3. That -3 is a special mencoder switch that calculates using the other dimension and the original aspect ratio. This is very important. If you hard code your dimensions and scale you'll end up with people with squished or stretched heads. This magic switch keeps your aspect ratio.
NOTE: See below, I no longer resize the videos because it isn't needed for the devices I use.
@echo off
REM By: Scott Kingery
REM email: techlifeblogged[at]gmail.com
REM Last updated 11:57 PM 4/4/2007REM Purpose: This batch file will look for mp4, m4v, mov, mpg and wmv files in the input folder you specify
REM and convert them to Divx 5 compatible files using the XVID codec.REM For this to work on your system you must enter the correct paths to various files.
REM **** Start User editable section ****
REM First you need to set the location of mencoder.exe
REM usually this is installed in c:\mplayer
REM Make sure of the location and put the path here
REM You can download the latest mplayer (which contains mencoder)REM from http://www1.mplayerhq.hu/MPlayer/releases/win32/
REM as of this writing the current version of mplayer for Windows is MPlayer-mingw32-1.0rc1set mencoderloc=c:\mplayer
REM inputdir is the location of files you want converted. Be sure to put in the complete path
REM to the TOP level directory. The script will look for and convert files in all subdirectories.
REM So if you have c:\dir1\dir2\dir3 and you specify inputdir as c:\dir1 the script
REM will convert all relevant files in dir1, dir2 and dir3
REM You can type it c:\dir1 or you can user system variables like %userprofile%set inputdir=%USERPROFILE%\Documents\My Received Podcasts
REM inplace tells the program what to do with the output.
REM Set inplace to 1 if you want the output file in the same directory as the input fileset inplace=1
REM If you would rather have the output somewhere else, set inplace to 0 (zero)
REM and set outdir to the directory you wantset outdir=%USERPROFILE%\Documents\My Converted Podcasts
REM If you want to keep the original, set backup to 1.
REM Setting it to 0 (zero) will cause the file to be deleted.set backup=1
REM If you do want a back up, set the directory you want the backups in here.
set backupdir=%USERPROFILE%\Documents\My Backup PodcastsREM Lastly, do you want to add today's date to the filename?
REM I include this because some places don't include the date in the file name and
REM this makes it hard to know what is new and what isn't when I look at it on my
REM device.
REM Setting incdate to 1 will cause the output to include todays date
REM For example, if an original file is called myshow.m4v and todays date is 18 March the output will be 20070318_myshow.aviset incdate=1
REM **** End User editable section ****
REM **** DO NOT EDIT BELOW THIS LINE ****
if %incdate% == 1 set TodayDate=%date:~-4,4%%date:~-10,2%%date:~-7,2%_
echo on
cd "%inputdir%"If %inplace% == 0 Goto ProcessMove
:ProcessInPlace
for /R %%i in ("*.mp4" "*.m4v" "*.mov" "*.mpg" "*.wmv") do %mencoderloc%\mencoder "%%i" -quiet -ovc lavc -lavcopts vcodec=mpeg4:v4mv:mbd=2:trell -vf expand=:::::4/3,scale=320:-3,harddup -oac mp3lame -lameopts fast:preset=medium -ffourcc DX50 -o "%%~dpi%TodayDate%%%~ni.avi"
for /R %%i in ("*.mp4" "*.m4v" "*.mov" "*.mpg" "*.wmv") do if exist "%%~dpi%TodayDate%%%~ni.avi" ren "%%i" "%%~nxi.converted"
Goto PostProc:ProcessMove
if not exist "%outdir%" md "%outdir%"
rem for /R %%i in ("*.mp4" "*.m4v" "*.mov" "*.mpg" "*.wmv") do %mencoderloc%\mencoder "%%i" -quiet -ovc lavc -lavcopts vcodec=mpeg4:v4mv:mbd=2:trell -vf expand=:::::4/3,scale=320:-3,harddup -oac mp3lame -lameopts fast:preset=medium -ffourcc DX50 -o "%outdir%\%TodayDate%%%~ni.avi"
for /R %%i in ("*.mp4" "*.m4v" "*.mov" "*.mpg" "*.wmv") do if exist "%outdir%\%TodayDate%%%~ni.avi" ren "%%i" "%%~nxi.converted":PostProc
If %backup% == 0 Goto DeleteOriginal:SaveOriginal
if not exist "%backupdir%" md "%backupdir%"
for /R %%i in ("*.converted") do move "%%i" "%backupdir%\%%~nxi"
Goto End:DeleteOriginal
for /R %%i in ("*.converted") do Del "%%i":End
UPDATE 20 MARCH 2008:
Since I originally wrote this how-to a new version of mencoder released. I now use MPlayer-mingw32-1.0rc2 which you can get from http://www1.mplayerhq.hu/MPlayer/releases/win32/
Additionally, I recommend downloading the additional codec packs from http://www.mplayerhq.hu/design7/dload.html I use windows-essential-20071007.zip
To install the codec pack, simply unzip the file and put its contents into c:\mencoder\codecs (assuming you installed Mencoder in c:\mencoder)
Also, I have updated the batch file as I no longer resize the video. I have left the old line in as examples should you still want to resize your videos.
I hope you found these instructions helpful. Let me know what devices you are using for you video podcasts and if you've changed any of the settings.
3 Comments:
Thanks, this is REALLY a useful script. These kind of automated scripts are hard to find. This is beyond me because it would seem that everyone would like to auto-convert their video podcasts...
Is the "rem" in the section :ProcessMove supposed to be there? It looks like a bug.
I can't wait to try the converted videos on my Clix2, which will arrive on Monday.
By
Patrick Dubois, at 7/28/2007 01:20:00 PM
Patrick, the REM was an oversite on my part. It can be deleted safely.
Additionally I've stopped scaling my videos. This works fine on my Archos but might not work on other devices. To NOT scale, simply change the bit after -vf to:
-vf pp=md,harddup
Glad you found the script useful.
By
Scott, at 7/28/2007 02:02:00 PM
I stumbled across this tonight and it looks exactly what I am looking for.
However, I am not too familiar with coding and I don't want to convert to DIVX or XVID. I want to convert DIVX/XVID/MPEG to a .WMV so that I can play on a ZUNE.
Please help me with changing the statement to achieve this.
Thanks...
By
matt, at 1/23/2008 08:15:00 PM
Post a Comment
Links to this post:
Create a Link
<< Home