Tuesday, May 27, 2008

How to convert DVD movie to .3gp

Most modern mobile phones can play movies in .3gp format. Here's an example, how to convert a movie on DVD to .3gp format. Of course this is not the only way how to do it:
  1. Open DVD Shrink, go to "Edit" -> "Preferences" -> "Output files" & uncheck "Split VOB files into 1GB size chunks
  2. open DVD, choose Re-author
  3. Drag the Main movie title into "DVD structure" window
  4. Go to "Compression settings", and choose only one language, uncheck all subtitles. Be sure that the video compression is set to 100% or "no compression" (although not mandatory, this is major time saver option)
  5. In the "DVD structure" windows, right click on the movie title, and choose "Set Start/End frames". This way you can remove unwanted frames from the beginning or the end of the movie .- e.g. opening and closing credits (again not mandatory, but it is space saver option)
  6. Click "Backup", in "Select backup target" choose "Hard disk folder", and set the target folder for DVD output files, e.g. "c:\movie"
  7. Click "OK" and wait a couple of minutes until DVDShrink finishes its job.
  8. Now go to DVD output folder (e.g. c:\movie) and rename the biggest file (something like VTS_01_1.VOB) to movie.mpg. You can delete all other files. Now you have a movie in one .mpg file, with one audio track and no subtitles. And in the same step we 've cut the credits from the movie.
  9. In the following steps we'll try go get some movie details, and figure out which parts of the movie we can cut
  10. Open movie.mpg in your favourite movie player, and pause at some bright scene
  11. press "Alt"+"Print Screen" on your keyboard, open paint (START->All programs->Accessories->Paint) and paste the clipboard (edit->paste)
  12. Zoom the spot just above the movie, and draw a line through the black part, that we want to crop from the final movie. Check the length of the line in the lower right corner of the paint window, and choose the next even number (in this example the length is 71 px, so we choose 72)
  13. Repeat the same procedure for the lower black part of the movie, for the movie width and the movie height. See the picture below:
  14. Now some simple math; our input movie is 1024x426. We want to resize it to 320 px width and keep the aspect ratio. So we can calculate the output height like that:
      • 1024/426=320/width => width = 133
      • we choose the next even value, so the size of our output movie will be 320x134
  15. In the next steps we'll convert the .mpg file to .3gp, using a command line tool "ffmpeg"
  16. Get the ffmpeg binaries here and extract the archive somewhere, e.g. c:\programs\ffmpeg (I got this version from super installation, because not all windows binaries have support for 3gp. This version does, at least it works on my system)
  17. open command line (START->Run->cmd)
  18. in terminal windows, type :
    1. > cd \programs\ffmpeg
    2. > ffmpeg.exe -i c:\movie\movie.mpg -croptop 72 -cropbottom 78 -vcodec mpeg4 -b 144k -bitexact -hq -s 320x134 -r 25 -acodec aac -ac 2 -ar 48000 -ab 24k -f 3gp c:\movie\movie.3gp
  19. Some explanation of the above command:
    • -i :input file
    • -croptop/-cropbottom :set crop top/bottom band size (what we've measured before)
    • -r :frame rate
    • -b :bitrate
    • -hq :higher quality
    • -s :output size (what we've measured and calculated before)
    • -acodec :audio codec
    • -ac :use 2 for stereo, 1 for mono
    • -ar :audio sampling rate
    • -ab :audio bitrate
    • -f :force format
  20. After a while you'll have a brand new .3gp movie, with the original aspect ratio, without black borders and without credits!
  21. transfer the movie.3gp file to your mobile phone and enjoy the silence of your kids watching the movie when you're in traffic jam ;-)

If you have time, you can use 2-pass encoding, which should produce a better quality movie. Although I'm not really sure if you'll spot any difference on your small mobile phone screen.
For 2-pass encoding use the following commands:
  • > ffmpeg.exe -i c:\movie\movie.mpg -croptop 72 -cropbottom 78 -vcodec mpeg4 -b 144k -bitexact -hq -s 320x134 -r 25 -acodec aac -ac 2 -ar 48000 -ab 24k -f 3gp -pass 1 c:\movie\movie.3gp
  • > ffmpeg.exe -i c:\movie\movie.mpg -croptop 72 -cropbottom 78 -vcodec mpeg4 -b 144k -bitexact -hq -s 320x134 -r 25 -acodec aac -ac 2 -ar 48000 -ab 24k -f 3gp -pass 2 c:\movie\movie.3gp

Some gui alternatives, if the procedure above is too complicated, although at my knowledge they can't handle movie in DVD format, but only a movie already in one file (.avi, .mpg or something):

No comments: