#!/bin/bash # some code taken from http://www.houghi.org/script/idvid - thanks! N_PASSES=1 # number of passes V_BITRATE=384 # video bitrate: 384 is default for simple profile level 3 A_BITRATE=128 # audio bitrate #Check for expect... expect_bin=`which expect | grep -c "expect"` file=${!#} TMP_DIR=`mktemp -d idvid-temp.XXXXXX` SCRATCH_FILE="$TMP_DIR/idvid.scratch" # Start with a clean scratch file rm -f "$SCRATCH_FILE" resultName=C2.${V_BITRATE}.${N_PASSES}pass-`echo "$file" | sed 's/\.\w*$//'` #resultName=C2-`echo "$file" | sed 's/\.\w*$//'` # get the framerate of the input file mplayer -vo null -ao null -frames 1 -channels 6 -identify \ "$file" > "$SCRATCH_FILE" 2>&1 #this basically sents an env. variable eval `cat "$SCRATCH_FILE" | grep "^ID_VIDEO_FPS"` #cleanup rm -r "$TMP_DIR" echo -e "\n$file framerate detected as being: $ID_VIDEO_FPS\n" # Set some frequently-used variables # Frames per second VFR=5 #default to 30fps case "$ID_VIDEO_FPS" in "23.976" ) VFR=1 ;; "24.000" | "24.00" | "24.0" | "24" ) VFR=2 ;; "25.000" | "25.00" | "25.0" | "25" ) VFR=3 ;; "29.970" | "29.97" ) VFR=4 ;; "30.000" | "30.00" | "30.0" | "30" ) VFR=5 ;; esac cmd="encode2mpeg -o \"$resultName\" -avionly -vfr $VFR -encode 2:2:$N_PASSES \ -acustom \"cbr:br=$A_BITRATE\" -vf harddup -vbitrate $V_BITRATE \ -setaspect 320 \"$file\"" if [ $expect_bin -eq "0" ]; then #no expect eval $cmd else #use expect so we don't have to press enter at the stupid #encode2mpeg warning about an unsupported version of mplayer expect - << EndMark spawn $cmd expect "Press return to proceed" { send "\n" } \ "Found video stream" { } #wait for a long time for it to finish (forever) set timeout -1 expect "JOBEND" EndMark fi echo "Done!"