Converting to 3gp

I wanted to play video on my Siemens M75. After some research, I found that the format is 3gp. Video files can be converted to this format using the Linux utility "ffmpeg".

Some notes on preparing ffmpeg:
* the utility should be downloaded from CVS,
* --enable-amr_nb should be given to the configure script,
* additional code should be downloaded to support --enable-amr_nb (Makefile prints details).

I spent much time choosing options for the best quality. Unfortunately, I haven't succeeded: sometimes video isn't smooth. The best options for me are:
* size: 176x144,
* bit rate: 30kbps,
* frame rate: 12fps.

The page "Watching movies on your phone" suggest improvements, and I followed them. It seems preprocessing by mencoder and mplayer gives better results.

The improved method is hard to use for a set of files, so I decided to write a wrapper script. To my disappointment, I forget how to write bash scripts. As solution, I decided to write a Makefile:


%.track.avi: %.avi
  mencoder '$< ' -nosound \\
    -ovc lavc -lavcopts vcodec=h263 \\
    -vop expand=176:144,scale=176:-2 -o '$@' -ofps 12

%.track.wav: %.avi
  mplayer -vo null \\
    -ao pcm -af resample=8000,volume=+16db:sc '$<'
  mv audiodump.wav '$@'

%.3gp: %.track.avi %.track.wav
  ~/opt/ffmpeg/bin/ffmpeg -i '$(word 1,$+)' -i '$(word 2,$+)' \\
    -vcodec h263 -b 30 -r 12 \\
    -acodec amr_nb -ac 1 -ab 12 \\
    -map 0.0 -map 1.0  '$@'

Usage is simple:

$ make -f ~/bin/Makefile-3gp.mk `ls *avi | sed 's/avi$/3gp/'`
Categories:

Updated: