Menu Home

Transcoding for the iPhone

This is definitely one of those “you’d better write this down” posts.

Being a longtime LINUX monkey, I am used to manipulating files via the command line. The GUI is a fad and if you want to get something done switch to command line. Transcoding video files are good for that sort of CLI manipulation.

Let’s say I had a .mkv file and wanted to play it on my iPhone. The iPhone does not play that format so I need to convert or transcode the video/audio/subtitles to something the iPhone can play.

It’s a two step process that requires two executable files for Windows, mencoder and ffmpeg. Doing a basic search on Google located the two binaries that I wanted and I put them in C:util.

The first one used is mencoder.exe and that’s to take the mkv formated file and convert it to an avi file. This is accomplished using this command:

C:utilmencoder.exe -mc 0 -noskip -oac mp3lame -lameopts cbr=128 -ovc xvid -xvidencopts bitrate=1200 "C:VideosEpisode-01.mkv" -o "C:tmpEpisode-01.avi"

This is an intermediate step since the iPhone can’t play avi files either.  Depending on the file this could take a while.  Once the output file Episode-01.avi has been generated then it’s time to use ffmpeg.

C:utilffmpeg.exe -threads 2 -i "C:tmpEpisode-01.avi" -acodec libfaac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2  -cmp 2 -subcmp 2 -s 640x352 -async 1 -title "Episode 01" "C:iPhone VideoEpisode-01.mp4"

I am running on a Intel Core 2 Duo so I use the -threads 2 option. After that’s completed, I just drag the new file into iTune’s and sync my phone.  The sync process will not transfer a video file that it thinks the iPhone will not play so even it iTunes can play it, the phone might not be able to.

There are GUI wrappers for this, but I could not get WinFF or Handbrake to work reliably for me. They both wrap the CLI commands, so this works out better for me. The quality is not that good outside of the iPhone but that’s what the original .mkv versions are for.

Now in 9 months, when I want to do this again, I’ll have the steps ready and wont waste the morning trying to remember what I did last year.

Categories: Cool Geek Software

Tagged as:

Jan Dembowski