Convert Your Videos to 3gp with ffmpeg
ffmpeg is a very nifty tool for audio and video conversion. It supports various formats. In my case, I was looking to convert a few videos that I had to 3gp format for viewing on my cell phone.
I had 2 choices – mencoder and ffmpeg but sadly neither of them supported 3gp videos on ubuntu. Since, I came across the post on using ffmpeg for 3gp videos on goinggnu I decided to go with ffmpeg. Even medibuntu repostiories do not have ffmpeg with 3gp support for Ubuntu 9.10(Karmic). So, only way ahead was to compile my own copy of ffmpeg
Firstly, I had to get ffmpeg from svn
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
You need to get following files from medibuntu repository
- libamrnb3
- libamrwb3
- amrnb
- amrwb
And then install ffmpeg
cd ffmpeg
./configure –enable-nonfree –enable-gpl –enable-pthreads
–enable-libopencore-amrnb –enable-libopencore-amrwb
–enable-version3 –enable-libmp3lame –enable-libxvid
make && checkinstall
NOTE: You need checkinstall installed on your system to complete the last step. Make sure that it is installed.
sudo apt-get install checkinstall
NOTE: I have enabled libmp3lame and libxvid in the above command, if you want support for those codecs, you will need to install libmp3lame-dev and libxvidcore4-dev. If you don’t want those, you can remove it from the configure command.
sudo apt-get install libmp3lame-dev libxvidcore4-dev
OK. Now you’re ready to convert your videos to 3gp format. You just need to use the following command
ffmpeg -i inputFile -s qcif -vcodec h263 -acodec libopencore_amrnb -ac 1 -ar 8000 -ab 12.2k -y outputFile
The above is the setting that worked best for me. You might want to make some changes according to what your device supports best. For example, you may want to use -f psp for your PSP. The options are nicely explained in ffmpeg documentation.
TIP: You can create a simple script out of the above command and use it everytime instead of having to remember it.
#!/bin/bash
/usr/local/bin/ffmpeg -i $1 -s qcif -vcodec h263 -acodec libopencore_amrnb -ac 1 -ar 8000 -ab 12.2k -y $2
Just put these 2 lines in a file and save it under /usr/bin and make it executable.
Now you can use this, let’s say we named it as 3gpconverter
3gpconverter inputFile outputFile
Enjoy your video on while on the go.


