[MPlayer-users] Script update

Meino Christian Cramer Meino.Cramer at gmx.de
Mon Jul 19 15:37:29 CEST 2004


Hi,

here is an updated version of the script

Have fun!
 Meino

#!/bin/sh
# ----------------------------------------------------------------------

# Language settings
export AID=129
export ALANG=de

# Size of target media: Uncomment the wanted size
# export TARGETSIZE=650    # 1 CD
export TARGETSIZE=700    # 1 CD
# export TARGETSIZE=800    # 1 CD
# export TARGETSIZE=1300   # 2 CD
# export TARGETSIZE=1400   # 2 CD
# export TARGETSIZE=1600   # 2 CD


# Your options to be given to lame
# stereo
export LAMEOPTS=mode=0:vbr=2:q=7
# mono
# export LAMEOPTS=mode=3:vbr=2:q=7

# Position and duration of the preview of encoding -- audio will be
# out of sync. This is OK
# Format hh:mm:ss
export PREVIEWSTART="00:01:00"
export PREVIEWDURATION="00:04:00"


# Your general options to mencoder
export OPTS="-vfm ffmpeg -vf denoise3d=0:0:0:hqdn3d=0:255:0:crop=696:576:14:0 -mc 0 -noskip -skiplimit 0"

# Your general options to ffmpeg/lavc, Bitrate settings anf vpass informations will
# be added later automagically
# color
export LAVOPTS=cbp:psnr:mbd=2:vcodec=mpeg4:autoaspect:trell:qpel   
# grayscaled
#export LAVOPTS=cbp:psnr:mbd=2:gray:vcodec=mpeg4:autoaspect:trell:qpel   

# ----------------------------------------------------------------------
# ========= NO USER CONFIGURABLE PARTS BEYOND THIS LINE ================
# ----------------------------------------------------------------------

# time the encoding process
export scriptstart=`date`


export LAVOPTS="${LAVOPTS}:vpass=#PASS#:vbitrate=#BITRATE#"
export TIMESLICE="-ss $PREVIEWSTART -endpos $PREVIEWDURATION"
export OPTS="-o $OFILEN $OPTS"

case $TARGETSIZE in
    650   ) export TARGET="Recommended video bitrate for 650MB"     ;;
    700   ) export TARGET="Recommended video bitrate for 700MB"     ;;
    800   ) export TARGET="Recommended video bitrate for 800MB"     ;;
    1300  ) export TARGET="Recommended video bitrate for 2 x 650MB" ;;
    1400  ) export TARGET="Recommended video bitrate for 2 x 700MB" ;;
    1600  ) export TARGET="Recommended video bitrate for 2 x 800MB" ;;
    *     ) echo "# ERR: Setup invalid! Check TARGETSIZE!"; exit 1  ;;
esac


# --- OPTARG HANDLING --------------------------------------------------

NO_ARGS=0 
E_OPTERROR=65

if [ $# -eq "$NO_ARGS" ]  
then
  echo "Usage: `basename $0` [-p [0-2]][-o outfile] [-t] -d <dir with video files>"
  exit $E_OPTERROR
fi  

export TS=""
export OFILEN="test.avi"
export MODE="-w"
export PASS=""
export MONO=""

while getopts "td:o:p:" Option
do
  case "$Option" in
    t     ) TS=$TIMESLICE; MODE="+w"                             ;; # activate test mode
    d     ) VOBDIR=$OPTARG                                       ;; # set directory w/ video
    o     ) OFILEN=$OPTARG                                       ;; # set ouput filename
    p     ) PASS=$OPTARG                                         ;; # activate a single pass
    *     ) echo "Unimplemented option chosen."; exit E_OPTERROR ;; # break on nonsense
  esac
done

# --- A LITTLE SANITY CHECKING -----------------------------------------

if [ -f $OFILEN ]
then
    if [ ! -w $OFILEN ]
    then
        echo
        echo "Target file already exists!"
        echo "Aborting..."
        Echo
        exit 1
    fi
fi

if [ ! -d $VOBDIR ]    
then
    echo
    echo "Directory with video files does not exist:" $VOBDIR
    echo "Aborting..."
    echo
    exit 1
fi

# --- TRANLATE ENCODING PASS SETTINGS ----------------------------------

case $PASS in
    0 ) PASS0=true; PASS1=false PASS2=false ;;
    1 ) PASS0=false; PASS1=true; PASS2=false ;;
    2 ) PASS0=false; PASS1=false; PASS2=true ;;
    * ) PASS0=true; PASS1=true; PASS2=true  ;;
esac    

if [ $PASS0 == true ]
then
    if [ -f frameno.avi ]
    then
        if [ ! -f PASS0.log ]
        then
            echo
            echo "# ERR: Audio file exists, but no logfile of PASS0 found...Aborting!"
            echo
            exit 1
        fi  
    else
        touch AUDIO.log
        echo
        echo -n "Extracting audio channel data ..."
        echo "----------------------------------------------------------------------" >> AUDIO.log
        echo "cat <video> | mencoder -ovc frameno -oac mp3lame -lameopts $LAMEOPTS  -alang $ALANG -aid $AID -o frameno.avi - " >> AUDIO.log
        echo "----------------------------------------------------------------------" >> AUDIO.log
        rxvt -title "### EXTRACTING AUDIO: PASS 0 ###" -e tail --follow=name AUDIO.log &
        cat $VOBDIR/*.vob | mencoder -ovc frameno -oac mp3lame -lameopts ${LAMEOPTS}  -alang $ALANG -aid $AID -o frameno.avi - >> AUDIO.log 2>&1
        mv AUDIO.log PASS0.log
        echo "...done"
    fi
fi

export BITRATE=`grep "$TARGET" PASS0.log | sed  's#.*\([0-9]\{4\}\)$#\1#'`
echo $BITRATE > bitrate.log

export LAVOPTS=`echo $LAVOPTS | sed 's|#BITRATE#|'$BITRATE'|'`
export PASS1LAVOPTS=`echo $LAVOPTS | sed 's|#PASS#|1|'`
export PASS2LAVOPTS=`echo $LAVOPTS | sed 's|#PASS#|2|'`


if [ $PASS1 == true ]
then
    echo -n "Extracting pass 1 of video..."
    touch PASScur1.log
    echo "----------------------------------------------------------------------" >> PASScur1.log
    echo "OPTIONS: cat <video> | mencoder $OPTS $TS -oac copy -ovc lavc -lavcopts $PASS1LAVOPTS -" >> PASScur1.log 
    echo "----------------------------------------------------------------------" >> PASScur1.log
    rxvt -title "### EXTRACTION VIDEO: PASS 1 ###" -e tail --follow=name PASScur1.log &
    (( cat $VOBDIR/*.vob | \
    mencoder $OPTS $TS -oac copy \
    -ovc lavc \
    -lavcopts ${PASS1LAVOPTS} - ) >> PASScur1.log 2>&1)
    mv PASScur1.log PASS1.log
    echo "...done"
fi

if [ $PASS2 == true ]
then
    echo -n "Extracting pass 2 of video..."
    touch PASScur2.log
    echo "----------------------------------------------------------------------" >> PASScur2.log
    echo "OPTIONS: cat <video> | mencoder $OPTS $TS -oac copy -ovc lavc -lavcopts $PASS2LAVOPTS -" >> PASScur2.log 
    echo "----------------------------------------------------------------------" >> PASScur2.log
    rxvt -title "### EXTRACTION VIDEO: PASS 2 ###"  -e tail --follow=name PASScur2.log &
    (( cat $VOBDIR/*.vob | \
    mencoder $OPTS $TS -oac copy \
    -ovc lavc \
    -lavcopts   ${PASS2LAVOPTS} - ) >> PASScur2.log 2>&1) 
    mv PASScur2.log PASS2.log
    echo "...done"
fi

chmod $MODE $OFILEN

export scriptend=`date`


echo
echo
cat PASS2.log | tail -1
echo "mencoder $OPTS $TS -oac copy -ovc lavc -lavcopts $PASS2LAVOPTS -" >> results.txt
cat PASS2.log | tail -1 >> results.txt
ls -l $OFILEN >> results.txt
echo "Started: $scriptstart / Ended: $scriptend" >> results.txt
echo "----------------------------------------------------------------------" >> results.txt
echo
echo
echo "--- FINISHED ---"




More information about the MPlayer-users mailing list