Watching movies on your phone

I'm now keeping a live journal, when I'm not administering my new site, for60secs.

I recently got a new phone - a Nokia 3650 - that can play video. The format is 3gp, a flavor of QuickTime. Nokia makes a Windows-based encoding tool, but I wanted to use ffmpeg. Using the latest (December 2003) CVS snapshot of ffmpeg it's possible to encode directly to 3gp using free software.

(My goal here was to be able to watch entire movies on my cellphone. I watch a lot of movies on DVD, and very often want to listen to the director's commentary tracks. Instead of sitting through the movie at home a second time, I can hear (and watch) the commentary next day on my phone.)

How?

Get the latest version of ffmpeg, look at ffmpeg/libavcodec/amr.c and follow the instructions in this file to enable amr/3gp support.

To convert the first 60 seconds of an AVI file:

./ffmpeg -i foo.avi
-s qcif -r 12          # convert video to 176x144 at 12 fps
-ac 1 -ar 8000         # convert audio to mono, 8000 Hz
-b 30                  # video rate 30kbps
-ab 12                 # audio rate 12kbps
-t 60                  # first 60 seconds only
foo.3gp                # output file

Choosing bitrates

There are some useful encoding guidelines here:

http://docs.real.com/docs/mobile/encoding_recommendations.pdf

I settled on 12fps QCIF, 30kbps video, 12kbps audio. At this rate, 30 minutes of movie takes 10 Mbytes.

Improvements

One problem is that the sound level is often too low in the source material. Another is that ffmpeg stretches the picture to fit the frame, which is fine for regular video but not right for anamorphic DVDs. Both these issues can be fixed by first using mencoder to extract video and audio streams, filtering these, then merging them back with ffmpeg.

Here's how:

  1. Extract video with mencoder. Scale to 176 wide, then center in a 176x144 frame.
    mencoder movie.vob \
    -nosound \
    -ovc lavc -lavcopts vcodec=mpeg4 \
    -vop expand=176:144,scale=176:-2 -o movie.avi -ofps 12
    
  2. Extract audio with mplayer. Resample to 8000Hz, turn up the volume with a soft clip filter.
    mplayer -vo null -ao pcm -af resample=8000,volume=+16db:sc movie.vob
    mv audiodump.wav movie.wav
    
  3. Combine audio and video with ffmpeg. Give ffmpeg the two input streams, then use the -map option to tell it which to read video and audio from.
    ffmpeg -i movie.avi
    -i movie.wav \
    -b 30 \
    -ac 1 -ab 12 \
    -map 0.0 -map 1.0 \
    movie.3gp
    

Transfer

Bluetooth is the obvious way to transfer files from a PC to the phone, and the video will appear as a Bluetooth message when the transfer is done. By default the phone stores messages in main memory, so there's a 4MB size limit. By changing the messaging options, however, you can get messages to go straight into the MMC, raising this limit to 16MB. I get about 1.2 megabytes/minute over Bluetooth.

A faster way is to remove the MMC card from the phone and put it in an MMC reader/writer. These cost under $20. But it isn't clear that the phone's battery and MMC sockets are designed for a large number of insertions.