All pastes #471225 Raw Edit

Miscellany

public shellscript v1 · immutable
·published 2007-05-04 20:06 UTC
rendered paste body
#!/bin/bash# some code taken from http://www.houghi.org/script/idvid - thanks!N_PASSES=1     # number of passesV_BITRATE=384  # video bitrate: 384 is default for simple profile level 3A_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 filerm -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 filemplayer -vo null -ao null -frames 1 -channels 6 -identify \    "$file" > "$SCRATCH_FILE" 2>&1#this basically sents an env. variableeval `cat "$SCRATCH_FILE" | grep "^ID_VIDEO_FPS"`#cleanuprm -r "$TMP_DIR"echo -e "\n$file framerate detected as being: $ID_VIDEO_FPS\n"# Set some frequently-used variables# Frames per secondVFR=5 #default to 30fpscase "$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        ;;esaccmd="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 $cmdelse    #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"EndMarkfiecho "Done!"