Monday, May 19, 2008

Convert Phone Video using FFMPEG

I recently shot some video using the camera on my HTC Touch Cruise. I was easily able to send it as an e-mail attachment using Pocket Outlook and my gMail account. However, when the video arrived it was in an unusable format so I had to do some FFMPEG processing on it.

FFMPEG reports that the Cruise records video as follows:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VIDEO0002.mp4':
Duration: 00:00:32.5, start: 0.000000, bitrate: 211 kb/s
Stream #0.0(eng): Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 30.00 tb(r)
Stream #0.1(eng): Audio: libamr_nb, 8000 Hz, mono

Quicktime normally has no problem playing MP4 videos, but in this case, it choked on the AMR audio stream. To get this video to play on my XP PC, I had to convert the audio but I didn't want to touch the video which was pretty poor quality to begin with. Here's the FFMPEG recipe I used:

ffmpeg -i VIDEO0002.mp4 -vcodec copy -ab 128k -ar 44100 NewVideo.mp4

The video stream is copied as is, so the operation is very quick and there is no loss in quality. The audio stream is converted from AMR to AAC. The conversion introduces additional losses, but the original audio is only mono, 8 KHz so it's not like you'll notice the loss. The result plays fine under Quicktime. FFMPEG says:

Output #0, mp4, to 'NewVideo.mp4':
Stream #0.0(eng): Video: mpeg4, yuv420p, 320x240 [PAR 0:1 DAR 0:1], q=2-31, 30.00 tb(c)
Stream #0.1(eng): Audio: libfaac, 44100 Hz, mono, 128 kb/s

Note that you'll have to have a build of FFMPEG with FAAC support.

Converting an HTC recording into a DivX file is a little more complex.

ffmpeg -i VIDEO0002.mp4 -vcodec libxvid -vtag DX50 -qscale 4 -acodec libmp3lame -ab 128k -ar 44100 video.avi

No comments:

Post a Comment