Jameser's Tech Tips

Friday, July 28, 2006

Tip #30: Creating 3GP Video for Mobile Phones with Free Tools

Today's tip is on creating high quality 3GP files for playback on newer mobile phones... Using free tools compiled for Windows, we will convert DVDs or existing AVI files using two-pass encoding for optimum results...

The free tools we'll be using to convert the video will be mencoder and mplayer from the MPlayer project, FAAC, as well as MPEG4 Tools from the MPEG4IP group... While there are point-and-click applications available for video conversion, I think you'll find that the approach below provides better results and smaller file sizes...

The examples assume you are converting from a DVD... If you are converting an AVI or MPG file, replace "-dvd-device e:\video_ts dvd://1 -aid 128" with the name of your video file...

(NOTE: The following commands should be entered on a single line, even though they may appear multiline on this page...)

Using mencoder, start the first pass of video encoding:

mencoder -dvd-device e:\video_ts dvd://1 -aid 128 -nosound -ovc lavc -lavcopts
vcodec=mpeg4:vbitrate=300:v4mv:mbd=2:trell:cmp=10:
subcmp=10:mbcmp=10:autoaspect:vpass=1 -ofps 14.985 -vf scale=320:240 -ffourcc DIVX -o c:\path\out.avi


Next, complete the second pass of video encoding:

mencoder -dvd-device e:\video_ts dvd://1 -aid 128 -nosound -ovc lavc -lavcopts
vcodec=mpeg4:vbitrate=300:v4mv:mbd=2:trell:cmp=10:
subcmp=10:mbcmp=10:autoaspect:vpass=2 -ofps 14.985 -vf scale=320:240 -ffourcc DIVX -o c:\path\out.avi


Next, we'll need to strip the audio from the source using the following command... This will consume a lot of disk space, so be certain to have a gigabyte or so available before continuing...

mplayer -dvd-device e:\video_ts dvd://1 -aid 128 -vo null -ao pcm:file=out.wav -af resample=16000,volume=3

Now, we'll need to encode the audio we just extracted into AAC format using faac:

faac -b 64 f4.wav -o f4.aac

Finally, we'll use mp4creator to combine our AVI and AAC files into our final 3GP using the following commands:

mp4creator -allow-avi-files -force3GPCompliance -create=ourfile.avi out.3gp

mp4creator -aac-profile=4 -interleave -force3GPCompliance -create=ourfile.aac out.3gp

mp4creator -optimize out.3gp

The resulting 3GP file should be playable on any device which supports 3GP files, and can also be played in quicktime... Change the vbitrate= in the video encoding commands if you'd like a smaller or larger file...

If you have any questions please leave a comment...

2 Comments:

  • At 11/16/2006 5:55 PM, Anonymous Anonymous said…

    Thanx for the post. Will use this for automatic linux scripts ;)). See you

     
  • At 1/01/2008 4:42 PM, Anonymous Anonymous said…

    I made an application using some of the tips from your tutorial. Thanks!

    http://www.stamcar.com/2008/01/01/enc3gp-gui/

     

Post a Comment

<< Home