Encoding Video for Cell Phones

Recently as many of you will know, I managed to get rid of the ridiculously appalling Skype S2 Phone, and replace it with a cheap, but very functional Sony Ericsson T715. Now, I’m not going to get into the various merits of each, suffice to say the SE has a decent resolution screen, at 320×240 and can handle a variety of video formats.

Right I said to myself, time to start a new project. The basic idea is this, I wanted to record a short video cast series using just my cell phone and a laptop. It seems doable. It seems reasonable. Yet I have to say I have come across my fair share of issues.

The premise for this video cast is that all “live” video has to be recorded on the phone itself. Screencasts are allowed and initially I wanted all editing to be done on my aging X41 laptop. More on this later. The first task was to get a video from my desktop in a format that the phone did not recognise, and convert it for use on the phone. A quick examination of the format the phone used led me to believe it was an MP4.

This is where video editing and encoding gets a little more complicated. You see, when you being looking at video files you will notice there are many types of files, MP4, WMV, 3GP, MOV, AVI etc. One would assume that if you can get a file from AVI to MP4 for example, that it would play perfectly well on the phone. Wrong.

You see the file formats are merely “containers”. In fact, that’s what they are called, “container formats”. They define a method for linking together and storing the audio and the video in a single file. The problem is that inside this “container” the audio and video can be stored in several different formats for each container.

A great tool, called mediainfo, is able to show you exactly what formats are stored inside each file to allow you to try and replicate this. The trick was to take a video created by the phone, and run it through mediainfo. I ended up with a listing, similar to this.

pete@satsuki:~/Videos$ mediainfo MOV00183.MP4
Complete name                    : MOV00183.MP4
Format                           : MPEG-4
Format profile                   : 3GPP Media Release 5
Codec ID                         : 3gp5
File size                        : 10.5 MiB
Duration                         : 2mn 5s
Overall bit rate                 : 704 Kbps
Encoded date                     : UTC 2010-01-07 09:09:15
Tagged date                      : UTC 2010-01-07 09:09:15

ID                               : 1
Format                           : MPEG-4 Visual
Format profile                   : Simple@L4a
Format settings, BVOP            : Yes
Format settings, QPel            : No
Format settings, GMC             : No warppoints
Format settings, Matrix          : Default (H.263)
Codec ID                         : 20
Duration                         : 2mn 5s
Bit rate mode                    : Variable
Bit rate                         : 671 Kbps
Nominal bit rate                 : 768 Kbps
Maximum bit rate                 : 1 536 Kbps
Width                            : 320 pixels
Height                           : 240 pixels
Display aspect ratio             : 4:3
Frame rate mode                  : Variable
Frame rate                       : 14.651 fps
Minimum frame rate               : 13.514 fps
Maximum frame rate               : 15.873 fps
Resolution                       : 8 bits
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.596
Stream size                      : 10.0 MiB (95%)
Language                         : Japanese
Encoded date                     : UTC 2010-01-07 09:09:15
Tagged date                      : UTC 2010-01-07 09:09:15

ID                               : 2
Format                           : AAC
Format/Info                      : Advanced Audio Codec
Format version                   : Version 4
Format profile                   : LC
Format settings, SBR             : No
Codec ID                         : 40
Duration                         : 2mn 5s
Bit rate mode                    : Variable
Bit rate                         : 31.1 Kbps
Nominal bit rate                 : 32.0 Kbps
Maximum bit rate                 : 64.0 Kbps
Channel(s)                       : 1 channel
Channel positions                : C
Sampling rate                    : 16.0 KHz
Stream size                      : 475 KiB (4%)
Language                         : Japanese
Encoded date                     : UTC 2010-01-07 09:09:15
Tagged date                      : UTC 2010-01-07 09:09:15

During my initial tests, I had wrongly assumed that the MP4 would be using the MPEG video format. When in fact, you can see above, it actually uses 3GP. After some tinkering, and a great deal of help from the #ffmpeg IRC channel, I can now present an ffmpeg line which gets me a MP4 playable file on my SE T715 phone.

/usr/bin/ffmpeg -i -f 3gp -vcodec mpeg4 -s 320x240 -g 250 -qscale 4 -mbd rd -trellis 1 -subcmp satd -acodec libfaac -ab 112kb -ar 16000 -ac 2

My troubles didn't end there, but I won't delve into those right now. Suffice to say I have had a nightmare getting videos to go into the editing software in "sync". I finally have a formula though and hopefully we'll be seeing the first episode very shortly.

  1. Ah, but the real question is, how do I unencode my phone’s crappy proprietary 3gp format into something playable?

    • Well, that may be doable…..can you run it through mediainfo and comment the result?

  2. I recently bought a touchphone from Samsung which comes without a camera and it’s storage can be expandable upto 8GB. It’s good for keep yourself entertained.
    I was converting The Wire show episodes with Video Bitrate of 256 Kbps and Audio Bitrate @ 96 Kbps. I started looking for information on the maximum video bitrate that my phone can handle. No luck. Your post actually gave me a start. My phone’s resolution is 320×240 and if your phone can record and play a video with a bitrate 671 I think I can try this number for conversion and see how it goes!


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: