Welcome!
A while back I wrote a script to convert my dvd collection into AVI files on my computer, which included the ability to auto-crop the black borders. I recently decided I wanted to start using the Matroska container instead of AVI. I again tried to accomplish this with GUI tools – many of them I evaluated previously such as WinFF and HyperVC and I also tried Avidemux and HandBrake GTK. WinFF/HyperVC wouldn’t run the encode for some reason when I selected the auto-crop features, and HandBrake GTK would not run at all on Karmic Koala giving GTK errors. Avidemux allowed me to set all the settings, and it worked – but the audio was invariably a-sync’d. I couldn’t find any settings with MP3, Vorbis, or FAAC that would properly sync with the video I was trying to convert.
So once again I had to resort to building my own. I use the same cropdetect.sh that is in my previous post and have just modified my mconverter.sh file to this:
#!/bin/sh<br />
for video in $@; do<br />
name=${video%.*}<br />
echo “Getting Crop Size”<br />
crop=
cropdetect.sh $video | awk -F 'crop=' '/crop/ {print $2}'
<br />
crop=echo $crop|sed 's/^[ ]*//'
<br />
echo “Starting Pass 1”<br />
which mencoder
“$video” -nosound -ovc x264 -x264encopts<br /> bitrate=1800:subq=5:bframes=3:<br />
b_pyramid:weight_b:turbo=1:threads=4:pass=1<br />
-passlogfile “$name.log” -o /dev/null -vf <br />
pullup,softskip,crop=$crop,harddup<br />
echo “Starting Pass 2”<br />
which mencoder
“$video” -nosound -ovc x264 -x264encopts<br /> bitrate=1800:subq=5:8x8dct:frameref=2:bframes=3:<br />
b_pyramid:weight_b:threads=4:pass=2<br />
-lameopts vbr=2:br=192:aq=3 -passlogfile “$name.log” -o<br /> "$name.264" -vf pullup,softskip,crop=$crop,harddup<br />
echo “Creating Audio”<br />
which mencoder
“$video” -alang “en” -ovc frameno -oac lavc -lavcopts acodec=vorbis:abitrate=224 -channels 2 -srate 48000 -o “audio.avi”<br />
echo “Creating MKV”<br />
which mkvmerge
-D “audio.avi” -A “$name.264” -o “$name.mkv”<br />
done<br />
This creates a MKV file using mencoder and mkvmerge (from mkvtoolnix) with the same name as the input file that has an h.264 encoded video at 1800 bitrate and a vorbis encoded audio with 2 channels. In my tests this has worked perfectly in providing sync’d audio and video and giving me good quality while saving space. A 6.6GB movie was compressed to 1.6GB with these settings and I can barely tell the difference when pausing the video’s side-by-side.
This is just another post that is more of a note for me in case I lose my scripts, but hopefully someone else out there manages to find use for it.
Happy Encoding!