diff options
Diffstat (limited to 'abs/core-testing')
-rw-r--r-- | abs/core-testing/linhes-scripts/PKGBUILD | 30 | ||||
-rwxr-xr-x | abs/core-testing/linhes-scripts/limit-mythcommflag.sh | 95 | ||||
-rwxr-xr-x | abs/core-testing/linhes-scripts/removecommercials.sh | 213 | ||||
-rw-r--r-- | abs/core-testing/tweaker/PKGBUILD | 4 | ||||
-rwxr-xr-x | abs/core-testing/tweaker/bin/twk_general.pl | 2 |
5 files changed, 312 insertions, 32 deletions
diff --git a/abs/core-testing/linhes-scripts/PKGBUILD b/abs/core-testing/linhes-scripts/PKGBUILD index f671142..02fba0e 100644 --- a/abs/core-testing/linhes-scripts/PKGBUILD +++ b/abs/core-testing/linhes-scripts/PKGBUILD @@ -3,7 +3,7 @@ pkgname=linhes-scripts pkgver=1 -pkgrel=57 +pkgrel=58 pkgdesc="Various scripts that help to make LinHES, LinHES." arch=('i686' 'x86_64') license=('GPL2') @@ -37,6 +37,7 @@ install_hulu.sh update_schema_021_to_022.sh upgrade_to_0.22.sh remove_php_mythvideo.sh +removecommercials.sh ) build() { @@ -102,3 +103,30 @@ md5sums=('f56985b2d602e11dc1e10d3e7848b2a5' '65629302a4d2c3adf88cdf0ebc10d493' 'ea5492d4dab8271db20cb84416c001dc' 'd7c7914225ec86bf3ea46104a364f977') +md5sums=('f56985b2d602e11dc1e10d3e7848b2a5' + '623b6e9ba6cc4a19771005e750f337a7' + '9ae2cd7a0c42d57ad8b5f515d7d60196' + '1274bad3fb7296f00acd2d44804bad14' + 'b4f858834ea92418208ab496ca39ad32' + '6b6e7d34a4bda6d608d150039adefd07' + '3fe554dbbf7d09e1f9925032ba888bf5' + '18263972b6326e140bbef0bb7dfa2da9' + '410795ef9039e4c6c0484e706ecfd567' + '0750d7c65109d12aa536f312a38410d1' + 'ac2a4a6b4100f4d7bfb9ecd9356c8c6e' + 'd2b475821f902c5e081e7da43a35e6ac' + '95c092f67036a361ef7a57436f44332e' + '3b776bbff68906ddc2f62b7e0dde3fe4' + '15f3143d2b1369da431e4268029aba40' + '3d0adf26280cde55a0c47188fff34826' + '93aaa2940e33ec9ebb305b839ac46a3e' + '972e42e02a11575da91f5e051d4de1d2' + 'b527b01d119d3bc33b8fa69bdf1082bb' + 'c537c44156d8404016cc4b405b092d45' + '4e66f302a77f1a857476e7f289d0c157' + 'be324dba44ae96676973a74421944853' + 'c9dc0dd07369622879a000247ac55074' + '65629302a4d2c3adf88cdf0ebc10d493' + 'ea5492d4dab8271db20cb84416c001dc' + 'd7c7914225ec86bf3ea46104a364f977' + '25c1baeb97a49656456ae33f7e7a9f06') diff --git a/abs/core-testing/linhes-scripts/limit-mythcommflag.sh b/abs/core-testing/linhes-scripts/limit-mythcommflag.sh index 8ca61c7..5cd81bb 100755 --- a/abs/core-testing/linhes-scripts/limit-mythcommflag.sh +++ b/abs/core-testing/linhes-scripts/limit-mythcommflag.sh @@ -1,6 +1,7 @@ #!/bin/bash -# limit-mythcommflag.sh v0.1 05/17/09 -# Utility to automatically limit mythcommflag if CPU usage is above a certain level. +# limit-mythcommflag.sh v0.2 03/2/10 +# Utility to automatically limit mythcommflag if CPU system load is above a certain level +# and if backend usage is above a certain level # Uses cpulimit from http://cpulimit.sourceforge.net/ # Free for any use. # Installation: @@ -8,47 +9,83 @@ # chmod +x /usr/LH/bin/limit-mythcommflag.sh # Usage: Executed from runit limit-mythcommflag at boot -# Threshold for when mythcommflag will be paused -CPUTHRESHOLD=43 - -# Limit mythcommflag to percentage -LIMITCPU=20 - -# Log file to write (use /dev/null for no log) -#LOG=/var/log/mythtv/limit-mythcommflag.log -LOG=/dev/null - +#-----OPTIONS______ # Number of seconds to wait between checking for mythcommflag process SLEEP=5 +# Backend and Frontend thresholds above which mythcommflag is stopped +BETHRESHOLD=30 +FETHRESHOLD=55 -#sleep $SLEEP +# FUNCTIONS +limit_cpu() +# Arg_1 = LimitedRangeNum; Arg_2 = CPULimitPercent; Arg_3 = Commflag PID +{ +if [ $ALREADYLIMITED -ne $1 ] ; then + if [ $cpulimit_pid -ne 0 ]; then + kill $cpulimit_pid + fi + cpulimit -p $3 -l $2 & + cpulimit_pid=$! + ALREADYLIMITED=$1 +fi +} -touch $LOG +stop_limit() +{ +if [ $ALREADYLIMITED -ne 0 ]; then + if [ $cpulimit_pid -ne 0 ]; then + kill $cpulimit_pid + cpulimit_pid=0 + fi + ALREADYLIMITED=0 +fi +} ALREADYLIMITED=0 +STOPPED=0 +cpulimit_pid=0 while true; do PROCCOMMFLAG=`pidof mythcommflag` - if [ -n "${PROCCOMMFLAG}" ] - then - FRONTENDCPU=`top -bn1u mythtv | grep mythfrontend | awk '{ print $9 }'` - if [ "$FRONTENDCPU" -ge "$CPUTHRESHOLD" ] - then - echo "$(date) FE CPU $FRONTENDCPU% is greater than $CPUTHRESHOLD%, LIMIT Commflagging" # >> $LOG - if [ $ALREADYLIMITED -eq 0 ]; then - cpulimit -e mythcommflag -l $LIMITCPU & - cpulimit_pid=$! - ALREADYLIMITED=1 + if [ -n "${PROCCOMMFLAG}" ]; then + BACKENDCPU=`top -bn1u mythtv | grep -m 1 mythbackend | awk '{ print $9 }'` + FRONTENDCPU=`top -bn1u mythtv | grep -m 1 mythfrontend | awk '{ print $9 }'` + if [ "$FRONTENDCPU" = "" ]; then + FRONTENDCPU=0 + fi + if [ "$BACKENDCPU" -ge "$BETHRESHOLD" ]; then + if [ "$FRONTENDCPU" -ge $FETHRESHOLD ]; then + if [ $STOPPED -eq 0 ]; then + kill -s STOP $PROCCOMMFLAG + STOPPED=1 + fi + else + if [ $STOPPED -eq 1 ]; then + kill -s CONT $PROCCOMMFLAG + STOPPED=0 + fi + stop_limit fi else - echo "$(date) FE CPU $FRONTENDCPU% is less than $CPUTHRESHOLD%, UNLIMIT Commflagging" #>> $LOG - if [ $ALREADYLIMITED -eq 1 ]; then - kill $cpulimit_pid - ALREADYLIMITED=0 + if [ $STOPPED -eq 1 ]; then + kill -s CONT $PROCCOMMFLAG + STOPPED=0 fi + case $FRONTENDCPU in + [0-9]|[0-3][0-9] ) + stop_limit;; + [4-5][0-9] ) + limit_cpu "1" "70" $PROCCOMMFLAG;; + [6-7][0-9] ) + limit_cpu "2" "50" $PROCCOMMFLAG;; + [8-9][0-9] ) + limit_cpu "3" "20" $PROCCOMMFLAG;; + [1][0-9][0-9] ) + limit_cpu "4" "10" $PROCCOMMFLAG;; + esac fi # else -# echo "No COMMFLAG Process Active" >> $LOG +# echo "No COMMFLAG Process Active" fi sleep $SLEEP done diff --git a/abs/core-testing/linhes-scripts/removecommercials.sh b/abs/core-testing/linhes-scripts/removecommercials.sh new file mode 100755 index 0000000..70e2e52 --- /dev/null +++ b/abs/core-testing/linhes-scripts/removecommercials.sh @@ -0,0 +1,213 @@ +#!/bin/sh +# remove commercials from recordings using the user generated cutlist or +# optionally using the mythcommflag generated cutlist. +# version 0.2 3/24/2010 + +# usage: +# first parameter must be %DIR% of the recording +# second parameter must be %FILE% of the recording +# third parameter must be %CHANID% +# fourth parameter must be %STARTTIME% +# fifth parameter must be %JOBID% for the User Job status to be updated in MythTV +# in the mythtv setup screen invoke this script like this: +# MYTHTV User Job Command: +# /usr/LH/bin/removecommercials.sh "%DIR%" "%FILE%" "%CHANID%" "%STARTTIME%" "%JOBID%" + +#-------OPTIONS---------------- +# If no cutlist is found USE_MYTHCOMMFLAG_CUTLIST=YES will use mythcommflag +# to generate a cutlist. +# WARNING: Using this option could result in part of the recording being cut if +# mythcommflag incorrectly flagged the commercial. +USE_MYTHCOMMFLAG_CUTLIST=NO + +# Auguments passed from command line +VIDEODIR=$1 +FILENAME=$2 +CHANID=$3 +STARTTIME=$4 +JOBID=$5 + +# database settings +BACKEND_HOSTNAME=${BACKEND_HOSTNAME:-"localhost"} +DBUSERNAME=${DBUSERNAME:-"mythtv"} +DBPASSWORD=${DBPASSWORD:-"mythtv"} +SQLCMD="mysql -u $DBUSERNAME --password=$DBPASSWORD -h $BACKEND_HOSTNAME mythconverg -e" + +LOG="/var/log/mythtv/removecommercials.log" + +#------FUNCTIONS--------------- +update_comment() +# Arg_1 = COMMENT +{ +if [ $NO_JOBID = 0 ]; then + `$SQLCMD "update jobqueue set comment=\"$1\" where id=\"$JOBID\";"` +fi +} + +update_status() +# Arg_1 = status code +{ +if [ $NO_JOBID = 0 ]; then + `$SQLCMD "update jobqueue set status=\"$1\" where id=\"$JOBID\";"` +fi +} + +check_myth_jobcmds() +# check the myth database for stop pause or resume commands +{ +if [ $NO_JOBID = 0 ]; then + CURRENT_CMD=`$SQLCMD "select cmds from jobqueue where id=\"$JOBID\";" | sed '/[0-9]/!d'` + case "$CURRENT_CMD" in + # JOB_RUN + 0) ;; + # JOB_PAUSE + 1) update_status 6 + kill -s STOP $TPID ;; + # JOB_RESUME + 2) update_status 4 + `$SQLCMD "update jobqueue set cmds=\"0\" where id=\"$JOBID\";"` + kill -s CONT $TPID ;; + # JOB_STOP + 4) update_status 5 + `$SQLCMD "update jobqueue set cmds=\"0\" where id=\"$JOBID\";"` + kill -9 $TPID + clean_up_files + echo "Cancelled" + update_status 320 + exit ;; + esac +fi +} + +check_background_progress() +#check progress in background +{ +while [ `tail -1 $STATUSFILE | grep -c "Done"` = 0 ] +do + sleep 5 + check_myth_jobcmds + current_status=`tail -1 $STATUSFILE` + if [ `expr match "$current_status" '.*\complete'` -ne 0 ]; then + prog_percent=`echo "$current_status" | awk '{print $3}'` + if [ -n "$prog_percent" ]; then + echo "Removing Commercials - $prog_percent Completed" + update_comment "Removing Commercials - $prog_percent Completed" + fi + fi +done +} + +get_pid() +{ +process_name="" +i1=1 +while [ "$process_name" != "found" ]; do + if [ "`ps $TPID | grep mythtranscode | sed 's_.*\(mythtranscode\).*_\1_'`" = "mythtranscode" ]; then + process_name="found" + else + TPID=`expr $TPID + 1` + fi + i1=`expr $i1 + 1` + if [ $i1 -gt 20 ]; then + break + fi +done +} + +clean_up_files() +# clean up left over files +{ +unlink $TMPFILE 2> /dev/null +unlink $TMPFILE.map 2> /dev/null +unlink $STATUSFILE 2> /dev/null +unlink $VIDEODIR/$FILENAME.tmp 2> /dev/null +} + +#-------MAIN SCRIPT------------ +# check if %JOBID% is passed from command line +JOBID=$5 +if [ -z "$JOBID" ]; then + NO_JOBID=1 +else + NO_JOBID=0 +fi +# check if file is a .mpg +if [ `expr match "$FILENAME" '.*\.mpg'` -ne 0 ]; then + MPEG="--mpeg2" +else + MPEG="" +fi + +# create temp filename so multiple instances won't conflict +TMPNAME=rmvCOMMS-$$ +TMPFILE=$VIDEODIR/$FILENAME-$$ +STATUSFILE=/myth/tmp/$TMPNAME-status.log + +touch $STATUSFILE + +update_status 4 + +check_myth_jobcmds + +# check for cutlist +MYTHCOMMFRAMES=`mythcommflag --getcutlist -f $VIDEODIR/$FILENAME | grep 'Cutlist:' | cut -d \ -f 2` + +if [ $USE_MYTHCOMMFLAG_CUTLIST=YES ] && [ -z "$MYTHCOMMFRAMES" ]; then + echo "Generating cutlist..." + update_comment "Generating cutlist..." + /usr/bin/nice -n19 /usr/bin/mythcommflag --gencutlist -f $VIDEODIR/$FILENAME + MYTHCOMMFRAMES=`mythcommflag --getcutlist -f $VIDEODIR/$FILENAME | grep 'Cutlist:' | cut -d \ -f 2` +fi + +if [ -n "$MYTHCOMMFRAMES" ]; then + echo "Removing Commercials..." + update_comment "Removing Commercials..." + ( /usr/bin/nice -n19 /usr/bin/mythtranscode -c $CHANID -s $STARTTIME -o $TMPFILE $MPEG --honorcutlist --showprogress > $STATUSFILE 2>&1 ; echo "Done" >> $STATUSFILE ) & + TPID=$! + get_pid + check_background_progress + ERROR=$? + if [ $ERROR -ne 0 ]; then + echo "Transcoding failed for ${FILENAME} with error $ERROR" + exit $ERROR + fi + + check_myth_jobcmds + # move temp file to output location + echo "Moving file..." + update_comment "Moving file..." + if [ `$SQLCMD "select data from settings where value='SaveTranscoding';" | sed '/[0-9]/!d'` = 1 ]; then + echo "DB is set to save transcoding" + mv $VIDEODIR/$FILENAME $VIDEODIR/$FILENAME.old + fi + mv $TMPFILE $VIDEODIR/$FILENAME + + # file has changed, rebuild index + echo "Rebuilding index..." + update_comment "Rebuilding index..." + mythcommflag -c $CHANID -s $STARTTIME --rebuild + ERROR=$? + if [ $ERROR -ne 0 ]; then + echo "Rebuilding seek list failed for ${FILENAME} with error $ERROR" + exit $ERROR + fi + + # remove old cutlist + echo "Removing old cutlist..." + update_comment "Removing old cutlist..." + mythcommflag -c $CHANID -s $STARTTIME --clearcutlist + ERROR=$? + if [ $ERROR -eq 0 ]; then + # Fix the database entry for the file + `$SQLCMD UPDATE recorded SET cutlist = 0, filesize = $(ls -l $VIDEODIR/$FILENAME | awk '{print $5}') WHERE basename = '$FILENAME';` > /dev/null + else + echo "Clearing cutlist failed for ${FILENAME} with error $ERROR" + exit $ERROR + fi + clean_up_files + echo "Commercials Removed" + update_status 272 + update_comment "Sucessfully Completed." +else + echo "No cutlist found." +fi diff --git a/abs/core-testing/tweaker/PKGBUILD b/abs/core-testing/tweaker/PKGBUILD index 79fc20d..85df000 100644 --- a/abs/core-testing/tweaker/PKGBUILD +++ b/abs/core-testing/tweaker/PKGBUILD @@ -1,6 +1,6 @@ pkgname=tweaker pkgver=1 -pkgrel=55 +pkgrel=56 pkgdesc="applies tweaks to the baseline configuration and attempts to optimize settings for the hardware it finds" arch=('i686' 'x86_64') @@ -41,3 +41,5 @@ build() { # Copy our tweaker Perl modules for general use install -m0555 lib/Tweaker/* $startdir/pkg/usr/lib/perl5/vendor_perl/Tweaker/ } +md5sums=('77fab526e866b273091e6816135ef25f' + 'e897b87dd308f9562d0867de9fab2de0') diff --git a/abs/core-testing/tweaker/bin/twk_general.pl b/abs/core-testing/tweaker/bin/twk_general.pl index 23572bc..f89912c 100755 --- a/abs/core-testing/tweaker/bin/twk_general.pl +++ b/abs/core-testing/tweaker/bin/twk_general.pl @@ -410,7 +410,7 @@ sub implement_option { change_or_make_setting('UserJob1', 'myth2ipod \"%DIR%\" \"%FILE%\"'); change_or_make_setting('UserJob2', 'myt2xvid3 \"%DIR%\" \"%FILE%\"'); change_or_make_setting('UserJob3', 'myth2x264 \"%DIR%/%FILE%\" \"%TITLE% - %SUBTITLE%\" \"%CHANID%\" \"%STARTTIME%\" \"%JOBID%\"'); - change_or_make_setting('UserJob4', 'removecommercials \"%DIR%\" \"%FILE%\" \"%CHANID%\" \"%STARTTIME%\" \"%JOBID%\"'); + change_or_make_setting('UserJob4', 'removecommercials.sh \"%DIR%\" \"%FILE%\" \"%CHANID%\" \"%STARTTIME%\" \"%JOBID%\"'); change_or_make_setting('UserJobDesc1', 'Transcode for iPod'); change_or_make_setting('UserJobDesc2', 'Transcode to xvid'); change_or_make_setting('UserJobDesc3', 'Transcode to h264'); |