#!/bin/sh fls=`ls *.avi | sort -n` i=1 n=`echo "${fls}" | wc -l` br=500 if [ $# -ge 1 ]; then br=$1; fi while [ $i -le $n ]; do #echo "TEST $i" file=`echo "${fls}" | sed -n "$i p"` # mencoder "$file" -oac mp3lame -lameopts vbr=2:aq=0:q=2 -ovc xvid -xvidencopts pass=1:bitrate=500:threads=2:turbo -vf scale=640:480 -o /dev/null # mencoder "$file" -oac mp3lame -lameopts vbr=2:aq=0:q=2 -ovc xvid -xvidencopts pass=2:bitrate=500:threads=2:turbo -vf scale=640:480 -o tmp.avi # First pass echo "First encoding pass for file $file" mencoder "$file" -oac mp3lame -lameopts vbr=2:aq=0:q=2 -ovc x264 -x264encopts pass=1:bitrate=${br}:threads=2:slow_firstpass:bframes=3:ref=6:qcomp=0.8:partitions=all:direct=auto:weightb:mixed-refs:8x8dct:trellis=1 -o /dev/null [ $? -ne 0 ] && exit 10 echo "Second encoding pass for file $file" mencoder "$file" -oac mp3lame -lameopts vbr=2:aq=0:q=2 -ovc x264 -x264encopts pass=2:bitrate=${br}:threads=2:bframes=3:ref=6:qcomp=0.8:partitions=all:direct=auto:weightb:mixed-refs:8x8dct:trellis=1 -o tmp.avi [ $? -ne 0 ] && exit 11 # Other sound streams process echo $# if [ $# -ge 2 ] && [ $2 -ge 1 ]; then is=2 #isn=$2 while [ $is -le $(($2+1)) ]; do # Get other sound streams echo "Get sound track $is from $file" mencoder "$file" -of rawaudio -aid $is -oac mp3lame -lameopts vbr=2:aq=0:q=2 -ovc copy -o sound_$is.mp3 [ $? -ne 0 ] && exit 12 # Merge other sound streams mv tmp.avi tmp1.avi echo "Merge sound track $is to result file" avimerge -i tmp1.avi -p sound_$is.mp3 -o tmp.avi [ $? -ne 0 ] && exit 13 rm tmp1.avi ((is=is+1)) done fi # Get other sound streams #mencoder La.Femme.Nikita.S01E01.1997-2001.DVDRip.avi -of rawaudio -aid 2 -oac mp3lame -lameopts vbr=2:aq=0:q=2 -ovc copy -o en.mp3 # Merge other sound streams #avimerge -i La.Femme.Nikita.S01E01.1997-2001.DVDRip_new.avi -p en.mp3 -o La.Femme.Nikita.S01E01.1997-2001.DVDRip_full.avi mv -f tmp.avi "$file" ((i=i+1)) done