Creating 3gp Videos with Linux

Creating the Video
Now it’s really time to create our 3gp file (with ffmpeg onyl!):

/opt/ffmpeg-svn/bin/ffmpeg -y -i My_Video_File.avi -vcodec h263 -s qcif -r 15 -b 125k -acodec libfaac -ac 1 -ar 32000 -ab 64k -f 3gp My_Video_File.3gp -cropleft 32 -cropright 32 -padtop 16 -padbottom 16 -vsync 2

Here’s the explanation of the switches:

  • -vcodec h263: This is the obligatory video codec for 3gp videos
  • -s gcif: This scales the video to 176×144 pixels
  • -r 15: 15 or 12 frames per second is usual for 3gp video.
  • -b 125k: The bitrate defines your video quality, but also your file size. Try values between ca. 40k and 200k.
  • -acodec libfaac: If you leave this out, it’ll try you use the amr_nb codec, which didn’t work for me.
  • -ac 1: I do this for a mobile phone, so one channel is enough, If your mobile do stereo, use a “2” instead.
  • -ar 32000: This is the audio sampling frequency. Lower values means lower quality and smaller output file size
  • -ab 64k: This is the audio bitrate. Lower values means lower quality and smaller output file size.
  • -f 3gp: This forces ffmpeg to create 3gp compliant output
  • -cropxxx and -padxxx: I’ve done this, because the source was a 16:9 flic, which doesn’t look good on a 4:3 screen. Adjust these values to your needs.

Mobile Media Converter
If you don’t like or just can’t compile for what reason ever, you can use also a already pre-build binary. This tool is under GPL and is working on 32 and 64 bit systems. I’m on a Kubuntu 9.04 (Jaunty Jackalope) and it worked for me.
You might add the crop and pad switches since it also uses ffmpeg to do the job, but more important than that, is the sync switch, since this tool doesn’t correct the desync problem. Just donwload the tar.gz file, change into the directory and start the ./MobileMediaConverter. You’ll get a GUI, so – yes – you’ll need X and a Window Manager to make use of this tool. Guys, thanks for this.

If you don’t like to read the whole text above, just perform these lines in order to create a .3gp video:

  • Install the audio codes:

    apt-get install libfaac-dev
  • Download the ffmpeg with svn. Install svn first, if you don’t have it (apt-get install subversion).
    svn co svn:// ffmpeg-svn
  • Go into the ffmpeg-svn directory and perform the appropriate configure. Do a make and install ffmpeg-svn if you like. It won’t break your installed ffmpeg, if you’re using the appropriate –prefix switch.
    cd ffmpeg-svn
    /configure --prefix=/opt/ffmpeg-svn --enable-pthreads --enable-gpl --enable-postproc --disable-stripping --enable-libfaac --enable-nonfree
    make && make install
  • Create now your 3gp file:
    /opt/ffmpeg-svn/bin/ffmpeg -y -i My_Video_File.avi -vcodec h263 -s qcif -r 15 -b 125k -acodec libfaac -ac 1 -ar 32000 -ab 64k -f 3gp My_Video_File.3gp -cropleft 32 -cropright 32 -padtop 16 -padbottom 16 -vsync 2


  • you don’t have to wait until the conversion process with ffmpeg has completed. You can press “q” on the keyboard anytime and verify if the result meets your needs.
  • The source video file can be any valid format ffmpeg understad. In the example above .avi is used, but it can be also .mkv or anything else, except transport streams (.ts and .m2ts from the satellite), but read ahead.
  • Before you can transcode a recording from the satellite (.ts), you have to remux it. I’ve done this for the following 830K 3gp sample. This example is done with these lines below, and is 30 seconds in lengh:
    aptitude install mencoder
    mencoder 001.vdr -ovc copy -oac copy -forceidx -o 001.avi
    /opt/ffmpeg-svn/bin/ffmpeg -y -i 001.avi -vcodec h263 -s qcif -r 15 -b 125k -acodec libfaac -ac 1 -ar 32000 -ab 64k -f 3gp 001.3gp

    where 001.vdr is my .ts file, which was created by my VDR

  • ffmpeg is also available for Windows of course. So this should work on Windows machines also. Feedback welcome.

2 thoughts on “Creating 3gp Videos with Linux

  1. It works! Thank you! Great write-up! Now I understand how to do it. Non-free codecs… that’s why mencoder and ffmpeg wouldn’t immediately work.

    That’s a ./configure in the third box in the Compendium, right?

    I had to do an “apt-get install yasm” to get ffmpeg to build.

    In the final step, ffmpeg didn’t like the cropleft, cropright, padtop or padbottom flags. Errors looked like:

    Option ‘cropleft’ has been removed, use the crop filter instead
    Option ‘padtop’ has been removed, use the pad filter instead

    I just tossed them. Movie finally works on my LG 900G.

Comments are closed.