Converting Droid Incredible .3gp movies to H.264/AAC/.mp4 in GNU/Linux

The movies recorded by the HTC Incredible are in .3gp format, MPEG-4, variable frame rate, with AMR-narrowband 8 KHz audio. The 720p video made possible with the Android 2.2 (Froyo) update averages about 18 fps, while the 800×480 video can do 30-32 fps. Overall, it’s a package which is not as compatible as it could be with media players (I would guess, at least—mplayer handles it fine), and the video is not very well compressed.

There is a package, mmediac, which would probably work but I didn’t see easy generic compilation instructions.

In my first attempts, avidemux choked, and maybe my test was bad but SUPER (eRightSoft, on Windows) didn’t like the videos either. So here is a bash script which works for me. This is single-pass encoding; I realize that two-pass would get me better results, but as I understand it, to take advantage of the needed-rate estimating ability of CRF mode with two pass, I would need to encode with CRF to get a file size, then divide to get a bit rate, then pass that bit rate to a two-pass command, for a total of three passes. Too much work! As it is, I get about a 50% reduction in file size and no noticeable quality loss. The video is sort of poor to start with anyway.

On Gentoo you would need the media-video/gpac, media-video/x264-encoder, media-sound/sox, media-video/ffmpeg, and media-libs/faac packages, at the least. The sox step could probably have been done by ffmpeg. And the 128 is overkill. Also, crf 22 is probably too conservative.



if [ $# -lt 2 ]; then
   echo 'Usage: dinc2mp4 ORIG.3GP NEW.MP4'

ffmpeg -y -vn -i "$1" -f wav temp_8.wav
sox temp_8.wav -r 48000 temp_48.wav rate
faac -o temp.m4a temp_48.wav -b 128 -w
x264 --crf 22 -o temp.mp4 "$1"
MP4Box -new -add temp.mp4 -add temp.m4a "$2"
rm temp.m4a temp.mp4 temp_48.wav temp_8.wav

Leave a Reply

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