Converting Video Files To 3GP For Use in Cell Phones

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

Requirements:

* 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:


#!/bin/sh

FILE=$1
shift

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 \
    "$FILE".3gp

Usage:

./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.

Acknowledgement:

* [blog.chris.de](http://blog.chris.de/index.php?/archives/22-Nokias-.3gp-Files.html)
* [allaboutsymbian.com](http://www.allaboutsymbian.com/forum/showthread.php?p=172181)
* [forums.gentoo.org](http://forums.gentoo.org/viewtopic-t-132849-highlight-3gp+ffmpeg.html)
* [excamera.com](http://excamera.com/articles/24/movie.html)

16 comments

  1. kalo kata gue sih paling gampang pake QuickTime :D … get a Mac :D …. mau mulus pake H.264 di 3GPP. Mau create 3GPP2 untuk CDMA juga moii.. :D

  2. #6: kalo udah beli Mac bisa buat macem2 pri, gak cuma convert video, hehe.. bisa pasang gentoo juga kalo mau :p

    QT7 (yg bisa H.264) kayaknya udah ada for Windows juga. Tapi masa mau convert video aja mesti pake Windows dulu :D

  3. bwahahaha…. si pri bukan ga mau, tapi udang kadung nginvest ThinkPad T42 nya kali :D wakakkaa… Udah sehat ga Pak? Masih di Bdg?

  4. pak, kalo mo rubah script mpplayer jadi 3gp dibagian mana sih rubahnya??

    trus kalo yg .AFS mo rubah jadi 3GP kok slalu kalo ada transisi gbr jadi kotak2 yah???

  5. Mas, aku punya file 3gp yang aku buat pake Benq-Siemens S88. Masalahnya, file yang seharusnya berdurasi 2 menit lebih tuh setelah aku pindahkan ke komputer kok cuman bisa dimainin selama 2 detik.

    Sedangkan file yang berukuran lebih kecil dari file ku nih dapat dimainkan dalam durasi yang lebih lama.

    Ini Mas, detail fileku.

    Summary:
    Duration: 00:00:02
    Bit rate: 14172kbps
    Video:
    Format: h263
    Size: 176×144
    Frame rate: 25.00fps
    Audio:
    Format: amr_nb
    Bit rate: 0kbps

    Ukuran filenya 3,45 MB

    Trims

  6. Hi! I dint use ur script though i figured out the ffmpeg command to use……basically its something like this:

    ffmpeg -i k.flv -ar 8000 -ac 1 -acodec amr_nb -vcodec h263 -s

    176×144 -r 12 -b 30 -ab 12 kk.3gp

    Both windows & posix users can use this command….thanks a lot!

Leave a Reply to Ronny Cancel reply

Your email address will not be published. Required fields are marked *