Creating 3gp Videos with Linux

For the impatient: Read here the compendium.

Recently I’ve bought a mid-range mobile phone for my wife. It’s a Nokia 2700 Classic for about 100€. At this price level you don’t have a sophisticated video support regarding recording or playback. You don’t have avi, wmv or flv support. The only video format the mobile phone understands is 3gp. And this only up to the breathtaking resolution of 176×144 pixels, what is also known as QCIF.
Of course SQCIF (128×96) is also supported, but not the next bigger CIF (352×288) or QVGA (320×240) format.
You may ask now, considering the limited resolution of the mobile phone, in my case QVGA, and the supported 3gp resolution of 177×144 (QCIF), what this all is really good for, and why the hell one should want to create a 3gp video file for a mobile device.

Why I Did It
Well – first of all, you could send anything you want via MMS, because 3gpp is an integral part of the MMS specification. But this wasn’t actually my intention. To be honest, I wanted to bring my son’s Micky Mouse and Winnie Pooh TV recordings to the mobile phone. Believe it or not, it’s a really easy way to bring this little brat to silence yet, while you are e.g. at doctor’s waiting room.
And he ain’t even complain about resolution, quality and stuff đŸ˜‰

You might have your own and maybe totally different reasons to create 3gp videos – these where mine, and this is how I did it with (of course) Linux and free software.
If you start looking with Google regarding this matter, you’ll likely find a few different approaches creating 3gp files. But none of those methods I’ve tried worked for me, at least not flawlessly.

And before you go ahead. There’s a reason, why I’m writing this. There is no out of the box solution for Linux for this, because the 3gp container includes codecs which aren’t free (nonfree). This means you won’t be able to create 3gp files by simply installing a default Debian package. We won’t do anything illegal, it’s only, that non-GPL software must not be included into the Debian repository, that’s all.

The Background
OK, here’s the beef. The 3gpp container accepts 2 different video, and 2 different audio formats.
The video formats are:

  • H263
  • H264

I’m sure, most of the mobile phones on earth do not support H264 yet, so we are bound to the H263, which is too, part of the MPEG-4 spec.

The audio codecs are:

  • AAC-LC

Right here our difficulties begin. Whereas the video codecs are open, the audio codecs, AMR-xx and AAC-xx ain’t. This means, they are not by default implemented in so mighty Linux tools like mencoder or ffmpeg.

This also means, we have to build the tool we are going to use ourself. Don’t be scared, there are also ways of using pre-build binaries.

I’ve stumbled over a few more or less different approaches, while I was looking through the Internet. But at the end it turned out, that all are using ffmpeg, and the latter have to be built from source, because the AAC or the AMR support is missing. If you try it with the debian ffmpeg package, you’ll get an: Unsupported codec for output stream #0.1.

So the first thing to do is, to build ffmpeg from source. This is quite easy, it’s done in a few lines. You don’t have to install your new compiled ffmpeg, if you don’t want to mess with an already installed ffmpeg version, just use it within the directory where you’ve built it.

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.