A video converter script I built using mencoder

In my Last Post I took a look at HyperVC and WinFF which were frontends for FFMPEG. HyperVC is also a frontend for Mencoder for people who prefer to use that.

One thing I found they both lacked was the ability to auto-crop the files in batch mode. So far the only Rip/Converting program I’ve seen that will allow that is the AcidRip – but it won’t auto-detect the crop sizes for Vob Files.

So again I went to google.. and found a script by someone named RC on mplayer’s archives called cropdetect.sh. I modified it slightly so that it only outputted the crop=w❌y:z numbers. Basically change this line:

echo -e "\n\nCrop Setting is: $CROP ... \n\n"

To say this:

echo -e "$CROP"

I then created a new, very basic, script using a command made from HyperVC, that will loop through all arguments passed and encode the videos one at a time using mencoder, with the proper crop settings, using H.264 (1800 bitrate) and MP3 (192kbit). I called this mconverter.sh.

#!/bin/bash for video in $@; do name=${video%\.*} crop=cropdetect.sh $video | awk -F ‘crop=’ ‘/crop/ {print $2}’ which mencoder "$video" -of avi -ovc x264 -oac mp3lame -x264encopts bitrate=1800 -lameopts vbr=2:br=192 -ofps 29.97 -o "$name.avi" -vf crop=$crop done

And for those that have to have their 2 pass encoding:

for video in $@; do name=${video%\.*} crop=$(cropdetect.sh $video | awk -F 'crop=' '/crop/ {print $2}') $(which mencoder) "$video" -of avi -ovc x264 -oac mp3lame -x264encopts bitrate=1800:pass=1 -lameopts vbr=2:br=192:aq=9 -ofps 29.97 -o /dev/null -vf crop=$crop -passlogfile $name.log $(which mencoder) "$video" -of avi -ovc x264 -oac mp3lame -x264encopts bitrate=1800:pass=2 -lameopts vbr=2:br=192:aq=2 -ofps 29.97 -o "$name.avi" -vf crop=$crop -passlogfile $name.log done

I put both of these files into my /usr/bin/ directory so they would be in my Arch Linux users $PATH.

You can run this script by doing:

mconverter.sh myfile.mpg my_other_file.vob my_other_other_file.mp4

You will get the filename with a .avi extension in the same place the other file is. This gets rid of those pesky top and bottom black borders on widescreen dvd’s. My Acer Aspire One netbook is already a widescreen, and 16:9 shows perfectly on it, why would i want to make the movie smaller with annoying black borders?

I know this isn’t much of a post.. I just needed somewhere to store my new script in case I lose it :). Maybe someone else will find it useful when converting their movies to their PC’s. I may update it later.. to accept more options/switches if I deem it gets enough attention.. right now it’s a simple loop.

For file sizes… I am getting 1.2-1.4GB files with this method for a typical DVD length movie. The quality is superb, IMHO.