Thursday, February 26, 2009

Watch Battlestar Galactica on Your Phone.

I have a crappy Nokia flip phone. There is nothing special about it. It does have a camera and can take really poor quality video if you happen to be standing in reasonable light. It does have have a media player to watch these videos which are formatted in .3gp, which I guess is very common in these small portable devices. I also have a 1 Gb micro SD card for storage on my phone. So far nothing too outlandish about this phone or it's features. These features are found on the most basic "free" phone given to you by carriers when you sign away your 1st born with one of their contracts. This is definately not a iPhone or some other overpriced "smartphone".

Anyway I wanted to see if I could watch Battlestar Galactica on my phone while on the bus to work each morning and found that it's not that difficult with Free open source software. My Battlestar Galactica episodes in .avi format, so I just needed a way to convert my .avi file to .3pg. Then put that newly created .3pg file on my microSD card and fire up my media player on my phone and I should be good to go. Here is how I did it.

Install the following: ffmpeg, amrnb, amrwb and sox. In debian based distros it's pretty straight forward with apt-get and each of these applications are in the Ubuntu repos. Then issue the follow command:

ffmpeg -i inputfile.avi -s qcif -vcodec h263 -acodec aac -ac 1 -ar 44100 -r 25 -ab 192 -y outputfile.3gp
Here is a brief breakdown of the ffmpeg command. You can find more detail on the ffmpeg man page.

-i input file
-s video size (qcif=176x144, see man page)
-vcodec video codec (needed for the conversion)
-acodec audio codec
-ac # if audio channels
-ar Audio frequency
-r Frame rate
-ab audio bitrate
-y output file

You may have to fiddle with the frame rate a bit to what works best for you on your device. I've converted one file and played it on 2 different devices and the audio and video sync was off on one and not the other, which tells me that something funky is going on with different media players. I would recommend that you keep the audio quality (freq and bitrate) high because the speakers on most of these low quality device are pretty crappy. You will want to have goo sound quality if you expect to hear anything.

A one hr long episode of Battlestar Galatica in .avi is about 350 mb, once converted to .3pg with the above configuration rates is about 80 mb.

If you have mpeg files you would like to convert, use the following:

ffmpeg -i inputfile.mpg -s qcif -vcodec h263 -acodec aac -ac 1 -ar 8000 -r 25 -ab 32 -y outputfile.3gp
If you're try to get videos off your phone to watch on your computer, here convert your files the other way.

ffmpeg -i clip.3gp -f avi -vcodec xvid -acodec mp3 -ar 22050 file.avi
Enjoy!

3 comments:

Devid said...

Nice Place to watch Battlestar Galactica.I am a hug fan of the show and watching the show Recently.

Anonymous said...

Battlestar Galactica is such a good show to watch and here I have read a wonderful post about this show. Thanks.

Anonymous said...

Thats really good news. Now I can watch my favorite show on my phone too. Thanks for this great information. Battlestar Galactica is my favorite show.