LinHES Forums http://forums.linhes.org/ |
|
Mythtranscode 232 Error repair query http://forums.linhes.org/viewtopic.php?f=25&t=22456 |
Page 1 of 1 |
Author: | bruce_s01 [ Fri Feb 24, 2012 9:36 am ] |
Post subject: | Mythtranscode 232 Error repair query |
I'm trying to update my script to fix the Mythtranscode 232 error to be used within myth from the transcode menu, using the framework of the removecommercials script. It seems to work pretty well, but there seems to be a logic error in original removecommercials script, where after going through the loop of waiting for the initial cutting of the file, it would print "done" to the log file, doing a couple of other ops and then checking for an error from the previous command, but this would have been no good looking for a fail in the commercial cut. For my script, what I need to do to is check the logfile for a fatal error for ffmpeg, but unfortunately I do not have an example of the output text, as the only time this happened, the logfile was still being deleted, and I was left with part of a TV programme that had been processed through the reindexing step.. Could anyone who has an example please post it here. Regards. Bruce S. |
Author: | bruce_s01 [ Mon Jun 18, 2012 5:37 am ] |
Post subject: | Re: Mythtranscode 232 Error repair query |
For those who are interested : Code: #!/bin/sh # Fix Mythtranscode 232 errors # Largely based on removecommercials # version 0.1 # 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/myth_fix232 "%DIR%" "%FILE%" "%CHANID%" "%STARTTIME%" "%JOBID%" # 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" #------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 $FPID ;; # JOB_RESUME 2) update_status 4 `$SQLCMD "update jobqueue set cmds=\"0\" where id=\"$JOBID\";"` kill -s CONT $FPID ;; # JOB_STOP 4) update_status 5 `$SQLCMD "update jobqueue set cmds=\"0\" where id=\"$JOBID\";"` kill -9 $FPID 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 $FPID | grep ffmpeg | sed 's_.*\(ffmpeg\).*_\1_'`" = "ffmpeg" ]; then process_name="found" else FPID=`expr $FPID + 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-$$.mpg STATUSFILE=/myth/tmp/$TMPNAME-status.log touch $STATUSFILE update_status 4 check_myth_jobcmds # check for cutlist echo "Remuxing File..." update_comment "Remuxing File" ( /usr/bin/nice -n19 ffmpeg -i $VIDEODIR/$FILENAME -acodec copy -vcodec copy "$TMPFILE" > $STATUSFILE 2>&1 ; echo "Done" >> $STATUSFILE ) & FPID=$! get_pid check_background_progress ERROR=$? if [ $ERROR -ne 0 ]; then echo "Remuxing 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 transcodeing" mv $VIDEODIR/$FILENAME $VIDEODIR/$FILENAME.old fi mv $TMPFILE $VIDEODIR/$FILENAME # file has changed, rebuild index echo "Rebuilding index" update_comment "Rebuilding index..." mythtranscode $MPEG --buildindex --allkeys --showprogress --chanid $CHANID --starttime $STARTTIME 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 "Error 232 Fixed" update_status 272 update_comment "Sucessfully Completed." Regards Bruce S. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |