30 July 2005

Converting Video Files To 3GP For Use in Cell Phones

Posted under: at 23:50

This is a very trivial shell script to convert video files from any video format supported by installed mplayer into the 3GPP (.3gp) format suitable for PDAs and cell phones.


  • ffmpeg with AMR support. This probably will cost you 95% of your effort, the rest is trivial. See the acknowledgement section on how to do this.
  • mplayer, with support for media format you are going to convert.
  • Truetype font for subtitles stored in ~/.mplayer/subfont.ttf. Use the parameter -sub subtitlefile.srt if you want to embed subtitles into resulting 3GPP video.

The script:



rm -f __tmp.avi
mencoder "$FILE" \
    -oac pcm \
    -ovc lavc \
    -lavcopts vcodec=mjpeg \
    -sws 2 \
    -vf scale=176:144 \
    -o __tmp.avi \
    -font ~/.mplayer/subfont.ttf  \
    -subfont-text-scale 4 \
    -subfont-blur 2 \
    -subfont-outline 1 \

rm -f "$FILE".3gp
ffmpeg \
    -i __tmp.avi \
    -ar 8000 \
    -ac 1 \
    -acodec amr_nb \
    -vcodec h263 \
    -s 176x144 \
    -r 12 \
    -b 30 \
    -ab 12 \


./to3gp.sh file-to-convert.avi [mencoder options ...]

You can adjust the parameters for ffmpeg if you want smaller file size or better quality. Consult man page for ffmpeg for more information.


16 Responses

Trackback: Use this URI to trackback this entry. Use your web browser's function to copy it to your blog posting.

Comment RSS: You can track conversation in this page by using this page's Comments RSS (XML)

Gravatar: You can have a picture next to each of your comments by getting a Gravatar.

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Warning: Comments carrying links to questionable sites will be removed!