summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2013-09-16 22:08:01 (GMT)
committerBritney Fransen <brfransen@gmail.com>2013-09-16 22:08:01 (GMT)
commit2c5a67ec9f7176f022449415a48f48d89cf0afad (patch)
tree5df6f12de751b985abc7e8a0661fa7821dbe3696 /abs/core/LinHES-system
parent13db4e5f492412b8127322169ffc8e75c3ea4ef4 (diff)
downloadlinhes_pkgbuild-2c5a67ec9f7176f022449415a48f48d89cf0afad.zip
linhes_pkgbuild-2c5a67ec9f7176f022449415a48f48d89cf0afad.tar.gz
linhes_pkgbuild-2c5a67ec9f7176f022449415a48f48d89cf0afad.tar.bz2
LinHES-system: move get_airplay_key, importfile.sh, myth2mkv, myth2mp3, and ripD_eject.sh from linhes-scripts
Diffstat (limited to 'abs/core/LinHES-system')
-rwxr-xr-xabs/core/LinHES-system/PKGBUILD14
-rwxr-xr-xabs/core/LinHES-system/get_airplay_key6
-rwxr-xr-xabs/core/LinHES-system/importfiles.sh18
-rw-r--r--abs/core/LinHES-system/myth2mkv433
-rwxr-xr-xabs/core/LinHES-system/myth2mp396
-rwxr-xr-xabs/core/LinHES-system/ripD_eject.sh125
6 files changed, 688 insertions, 4 deletions
diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD
index 03e5eca..ee79c88 100755
--- a/abs/core/LinHES-system/PKGBUILD
+++ b/abs/core/LinHES-system/PKGBUILD
@@ -1,6 +1,6 @@
pkgname=LinHES-system
pkgver=8.0
-pkgrel=13
+pkgrel=14
arch=('i686' 'x86_64')
install=system.install
pkgdesc="Everything that makes LinHES an automated system"
@@ -8,12 +8,13 @@ license=('GPL2')
depends=('linhes-sounds' 'xdotool' 'tilda' 'keylaunch'
'python_aosd' 'udisks' 'LinHES-config>=2.3-59' 'sudo'
'python2-dbus' 'unclutter' 'wmctrl' 'archlinux-xdg-menu'
- 'ethtool' 'gnu-netcat')
+ 'ethtool' 'gnu-netcat' 'normalize'
+ 'handbrake-cli' 'mkvtoolnix' 'mplayer')
backup=('etc/modprobe.d/alsa-base.conf')
binfiles="LinHES-start optimize_mythdb.py myth_mtc.py myth_mtc.sh
LinHES-run load-modules-mythvantage.sh unclutter-toggle.sh tvterm.sh
mythfrontend-start set_windowmanager.sh myth_status.py myth_status.sh
- install_supplemental_service.sh
+ install_supplemental_service.sh get_airplay_key importfiles.sh
lh_system_backup lh_system_backup_job lh_system_restore_job
lh_system_host_update lh_system_all_host_update
add_storage.py diskspace.sh cacheclean lh_backend_control.sh
@@ -23,7 +24,7 @@ binfiles="LinHES-start optimize_mythdb.py myth_mtc.py myth_mtc.sh
misc_upcoming_recordings.pl misc_which_recorder.pl
change_channel.sh change_channel_wrapper.sh stop_xss.sh
be_check.py checkXFSfrag.sh find_orphans.py idle.sh xwin_find.sh
- linhes_update.sh linhes_update2.sh
+ linhes_update.sh linhes_update2.sh myth2mkv myth2mp3 ripD_eject.sh
mythwelcome-config.py mythwelcome-set-alarm.sh mythwelcome-test-wakeup.sh"
source=(LinHES-session LinHES-profile.sh $binfiles
@@ -86,6 +87,8 @@ md5sums=('8fc4b7c1ddf8f3c4d2266ce55086b4d4'
'692563448cca1d49f45e7d1c8abcaa0c'
'962a3e9eaba2d1466251b7ab0956705d'
'1758aed160de64abfafb28a3a8f3390e'
+ '33fbebbd546672cedd3c5e7350ab414e'
+ '6b6e7d34a4bda6d608d150039adefd07'
'3edef50a49a47694bf8add39cc160add'
'5e17e0786afd891550a660f646076308'
'bc69a520add58ede9b060c73e67ace13'
@@ -118,6 +121,9 @@ md5sums=('8fc4b7c1ddf8f3c4d2266ce55086b4d4'
'a94fe6d980f4b810f2e2ae5352084b39'
'e1011e0df090372cccc03ecf9d6805c7'
'd14335afe7dafa035a70399210e0df1a'
+ '503df99218373dfc75e7e7f5e449a44e'
+ '4a1fda884dcd7d65fb2690fbdbd92a83'
+ 'e2e24dd59d5d576cc33feafb329fa302'
'92950f0ffb1faf1ed64c6be2b8fbc3f6'
'95c092f67036a361ef7a57436f44332e'
'410795ef9039e4c6c0484e706ecfd567'
diff --git a/abs/core/LinHES-system/get_airplay_key b/abs/core/LinHES-system/get_airplay_key
new file mode 100755
index 0000000..89a40dd
--- /dev/null
+++ b/abs/core/LinHES-system/get_airplay_key
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+. /usr/MythVantage/bin/install_functions.sh
+curl https://raw.github.com/juhovh/shairplay/master/airport.key > $MYTHHOME/.mythtv/RAOPKey.rsa
+chmod 755 $MYTHHOME/.mythtv/RAOPKey.rsa
+chown mythtv:mythtv $MYTHHOME/.mythtv/RAOPKey.rsa \ No newline at end of file
diff --git a/abs/core/LinHES-system/importfiles.sh b/abs/core/LinHES-system/importfiles.sh
new file mode 100755
index 0000000..84f1ab5
--- /dev/null
+++ b/abs/core/LinHES-system/importfiles.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+export FONT="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*"
+
+DVD_or_CD=`cat /proc/mounts |grep iso9660|awk '{print $2}'|tail -1`
+if [ "$DVD_or_CD" != "" ]; then
+ echo "Copying files from $DVD_or_CD to /myth/video." > /tmp/screens
+ echo "This could take several minutes, depending on the" >> /tmp/screens
+ echo "speed and size of your optical media." >> /tmp/screens
+ cat /tmp/screens | osd_cat --font=$FONT --shadow=3 --pos=middle --align=centre --color=yellow --delay=0 &
+ /bin/cp -R $DVD_or_CD/* /myth/video/
+ killall osd_cat
+ echo "Copied videos from $DVD_or_CD to /myth/video" > /tmp/screens
+ cat /tmp/screens | osd_cat --font=$FONT --shadow=3 --pos=middle --align=centre --color=yellow --delay=2 &
+else
+ echo "No optical media found. If you just inserted" > /tmp/screens
+ echo "your media, please wait a moment and try again." >> /tmp/screens
+ cat /tmp/screens | osd_cat --font=$FONT --shadow=3 --pos=middle --align=centre --color=yellow --delay=5 &
+fi
diff --git a/abs/core/LinHES-system/myth2mkv b/abs/core/LinHES-system/myth2mkv
new file mode 100644
index 0000000..aedccff
--- /dev/null
+++ b/abs/core/LinHES-system/myth2mkv
@@ -0,0 +1,433 @@
+#!/bin/bash
+#
+# Convert video to AVC-1 / h264
+#
+# version 0.25-004
+#
+# Prerequisites:
+# - mythtv >= 0.25
+# - handbrake-cli
+# - mplayer
+# - mkvtoolnix
+#
+# Arguments
+# $1 must be the directory/file of the recording
+# $2 must be chanid
+# $3 must be starttime
+# $4 must be title
+# $5 must be subtitle
+# $6 must be jobid
+# $7 must be quality of encode
+#
+# As a MythTV user job:
+# myth2mkv "%DIR%/%FILE%" "%CHANID%" "%STARTTIME%" "%TITLE%" "%SUBTITLE%" "%JOBID%" HQ|MQ|LQ
+
+########################
+# #
+# Adjustable variables #
+# #
+########################
+
+OUTDIR=/myth/video
+LOGPATH=/var/log/mythtv
+LOGFILE=${LOGPATH}/myth2mkv-$$.log
+
+# TMPDIR is for large transient files
+TMPDIR=/myth/tmp
+
+# x264 tuning:
+# Tune x264 based on content. Valid options for TUNING are:
+# film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency
+# Separate multiple options with a comma. DEFAULT: none
+TUNING=""
+
+# Custom cropping. Useful if you have a 4:3 image in a HD frame or if
+# HandBrake's autocrop smarts fail you.
+# Crop 240 pixels off the left and right for 4:3 image in 1920x1080 frame
+# Crop 160 pixels off the left and right for 4:3 image in 1280x720 frame
+# <T:B:L:R>
+# i.e. 0:0:240:240
+# Default: In HQ: CROP="0:0:0:0" (no cropping).
+# IN MQ and LQ: autocrop.
+CROP=""
+
+# Force custom output resolution.
+# Default: Keep same resolution as input file (less any cropping).
+WIDTH=""
+HEIGHT=""
+
+# Force use/non-use of deinterlacing filter. Y|N|G (Yes, No, Guess)
+# Default: G - Guess based on source resolution.
+# If the source video width is 1920, 1440, 852, 704, 640 or 528 pixels
+# "G" will deinterlace the video. Change to "Y" to force use of deinterlacing
+# filter or to "N" to NOT use deinterlace filter no matter the resolution.
+DEINT="G"
+
+############################
+# #
+# End adjustable variables #
+# #
+############################
+
+if [[ -e $HOME/.mythtv/mysql.txt ]] ; then
+ . $HOME/.mythtv/mysql.txt
+else
+ DBHostName=${DBHostName:-"localhost"}
+ DBUserName=${DBUserName:-"mythtv"}
+ DBPassword=${DBPassword:-"mythtv"}
+ DBName=${DBName:-"mythconverg"}
+fi
+
+if [[ ! -d ${TMPDIR} ]] ; then
+ mkdir -p ${TMPDIR}
+fi
+
+if [[ ! -d ${OUTDIR} ]] ; then
+ mkdir -p ${OUTDIR}
+fi
+
+#------FUNCTIONS---------------
+update_comment()
+# Arg_1 = COMMENT
+{
+if [ ${NO_JOBID} -eq 0 ]; then
+ SQL_CMD="update jobqueue set comment=\"${1}\" where id=\"${JOBID}\";"
+ `${MYSQLCMD} "${SQL_CMD}"`
+fi
+}
+
+check_background_progress()
+# check handbrake progress in background
+{
+while [ `tail -2 ${STATUSFILE} | grep -c "^HandBrake has exited"` = 0 ]
+do
+ sleep 10
+ check_myth_jobcmds
+ pass=`tail -1 ${STATUSFILE} | egrep -o -e 'task [0-9]' | tail -1 | sed 's/task\ //g'`
+ prog_percent=`tail -1 ${STATUSFILE} | egrep -o -e '[0-9]*\.[0-9]. %' | tail -1 | sed 's/\ %//g'`
+ current_FPS=`tail -1 ${STATUSFILE} | egrep -o -e 'avg [0-9.]*\.[0-9]* fps' | tail -1 | sed -e 's/avg\ //g' -e 's/\ fps//g'`
+ current_ETA=`tail -1 ${STATUSFILE} | egrep -o -e 'ETA [0-9.][0-9.]h[0-9.][0-9.]m[0-9.][0-9.]s' | tail -1`
+ if [ -n "$prog_percent" ]; then
+ echo "Pass ${pass}, ${prog_percent}% @ ${current_FPS} fps. ${current_ETA}"
+ update_comment "Pass ${pass} of 2, ${prog_percent}% @ ${current_FPS} fps. ${current_ETA}"
+ fi
+ sleep 10
+done
+}
+
+check_myth_jobcmds()
+# check the myth database for stop pause or resume commands
+{
+if [[ ${NO_JOBID} -eq 0 ]] ; then
+ CURRENT_CMD=`${MYSQLCMD} "select cmds from jobqueue where id = \"${JOBID}\";"`
+ case "${CURRENT_CMD}" in
+ # JOB_RUN
+ 0) ;;
+ # JOB_PAUSE
+ 1) `${MYSQLCMD} "update jobqueue set status=\"6\" where id=\"${JOBID}\";"`
+ kill -s STOP ${handbrake_pid} ;;
+ # JOB_RESUME
+ 2) `${MYSQLCMD} "update jobqueue set status=\"4\" where id=\"${JOBID}\";"`
+ `${MYSQLCMD} "update jobqueue set cmds=\"0\" where id=\"${JOBID}\";"`
+ kill -s CONT ${handbrake_pid} ;;
+ # JOB_STOP
+ 4) `${MYSQLCMD} "update jobqueue set status=\"5\" where id=\"${JOBID}\";"`
+ `${MYSQLCMD} "update jobqueue set cmds=\"0\" where id=\"${JOBID}\";"`
+ kill -9 ${handbrake_pid} ${command_pid}
+ clean_up_files
+ echo "Encode Cancelled" >> ${LOGFILE}
+ `${MYSQLCMD} "update jobqueue set status=\"320\" where id=\"${JOBID}\";"`
+ exit ;;
+ esac
+fi
+}
+
+get_info_for_hb() {
+# Collect some info about source file
+
+/usr/bin/mplayer -nolirc -identify -frames 0 "${HBINPUTFILE}" \
+ 2>/dev/null 1>"${IDFILE}"
+
+VIDEOW=$( grep ID_VIDEO_WIDTH= "${IDFILE}" | awk -F= '{ print $NF }' )
+FPS=$( grep ID_VIDEO_FPS= "${IDFILE}" | awk -F= '{ print $NF }' )
+
+# HandBrake does not like a framerate of 29.970, so let's drop the 0
+if [[ ${FPS} = "29.970" ]] ; then
+ FPS="29.97"
+fi
+
+# HandBrake does not like a framerate of 59.940, so let's drop the 0
+if [[ ${FPS} = "59.940" ]] ; then
+ FPS="59.94"
+fi
+
+# A rough guestimation that if the video width is 1920, 1440, 852, 704, 640 or
+# 528 pixels it is probably interlaced.
+if [[ ${DEINT} = Y ]] ; then
+ DEINT="-d slow"
+else
+ if [[ ${DEINT} = N ]] ; then
+ DEINT=""
+ else
+ if [[ ${VIDEOW} = 1920 || ${VIDEOW} = 1440 || ${VIDEOW} = 852 || \
+ ${VIDEOW} = 704 || ${VIDEOW} = 640 || ${VIDEOW} = 528 ]] ; then
+ DEINT="-d slow"
+ else
+ DEINT=""
+ fi
+ fi
+fi
+
+if [[ -n ${DEINT} ]] ; then
+ if [[ ${QUALITY} = LQ ]] ; then
+ DEINT="-d fast"
+ fi
+fi
+
+if [[ -n ${TUNING} ]] ; then
+ TUNING="--x264-tune ${TUNING}"
+fi
+
+if [[ -n ${CROP} ]] ; then
+ CROP="--crop ${CROP}"
+fi
+
+if [[ -n ${WIDTH} ]] ; then
+ WIDTH="-w ${WIDTH} -X ${WIDTH}"
+fi
+
+if [[ -n ${HEIGHT} ]] ; then
+ HEIGHT="-l ${HEIGHT} -Y ${HEIGHT}"
+fi
+
+if [[ ${QUALITY} = HQ ]] ; then
+ if [[ -n ${CROP} ]] ; then
+ CROP="--crop ${CROP}"
+ else
+ CROP="--crop 0:0:0:0 --strict-anamorphic"
+ fi
+ HB_OPTS="-o ${TMPFILE} -f mkv -m -e x264 ${TUNING} -x b-adapt=2:rc-lookahead=50 -b 5000 -2 -T ${WIDTH} ${HEIGHT} -r ${FPS} --cfr ${CROP} ${DEINT} -a 1 -E copy -s 1"
+else
+ if [[ ${CROP} = "--crop 0:0:0:0" ]] ; then
+ CROP="${CROP} --strict-anamorphic"
+ fi
+ if [[ ${QUALITY} = LQ ]] ; then
+ HB_OPTS="-o ${TMPFILE} -f mkv -m -e x264 ${TUNING} -b 1250 ${WIDTH} ${HEIGHT} -r ${FPS} --pfr ${CROP} ${DEINT} -a 1 -E lame -B 128 -Q 8 -6 stereo -s 1"
+ else
+ # Fallback to "MQ"
+ HB_OPTS="-o ${TMPFILE} -f mkv -m -e x264 ${TUNING} -b 2500 -2 -T ${WIDTH} ${HEIGHT} -r ${FPS} --pfr ${CROP} ${DEINT} -a 1 -E lame -B 256 -Q 3 -6 stereo -s 1"
+ fi
+fi
+}
+
+get_handbrake_pid()
+{
+process_name=""
+i1=1
+while [ "${process_name}" != "found" ]; do
+ handbrake_pid=`expr ${handbrake_pid} + 1`
+ i1=`expr ${i1} + 1`
+ if [ "`ps ${handbrake_pid} | grep HandBrakeCLI | sed 's_.*\(HandBrakeCLI\).*_\1_'`" = "HandBrakeCLI" ]; then
+ process_name="found"
+ fi
+ if [ ${i1} -gt 20 ]; then
+ break
+ fi
+done
+}
+
+tag_file() {
+DATE=`date`
+
+# Create a tag file here
+echo "<?xml version='1.0' encoding='ISO-8859-1'?>" > "${TAG_FILE}"
+echo "" >> "${TAG_FILE}"
+echo "<!DOCTYPE Tags SYSTEM 'matroskatags.dtd'>" >> "${TAG_FILE}"
+echo "" >> "${TAG_FILE}"
+echo "<Tags>" >> "${TAG_FILE}"
+echo " <Tag>" >> "${TAG_FILE}"
+echo " <Simple>" >> "${TAG_FILE}"
+echo " <Name>TITLE</Name>" >> "${TAG_FILE}"
+echo " <String>${TITLE}</String>" >> "${TAG_FILE}"
+echo " <Simple>" >> "${TAG_FILE}"
+echo " <Name>SUBTITLE</Name>" >> "${TAG_FILE}"
+echo " <String>${SUBTITLE}</String>" >> "${TAG_FILE}"
+echo " <Simple>" >> "${TAG_FILE}"
+echo " <Name>SUMMARY</Name>" >> "${TAG_FILE}"
+echo " <String>${DESCR}</String>" >> "${TAG_FILE}"
+echo " </Simple>" >> "${TAG_FILE}"
+echo " <Simple>" >> "${TAG_FILE}"
+echo " <Name>DATE_RELEASED</Name>" >> "${TAG_FILE}"
+echo " <String>${OAD}</String>" >> "${TAG_FILE}"
+echo " </Simple>" >> "${TAG_FILE}"
+echo " </Simple>" >> "${TAG_FILE}"
+echo " </Simple>" >> "${TAG_FILE}"
+echo " <Simple>" >> "${TAG_FILE}"
+echo " <Name>ENCODER</Name>" >> "${TAG_FILE}"
+echo " <String>HandBrakeCLI ${HBCLIVER}</String>" >> "${TAG_FILE}"
+echo " </Simple>" >> "${TAG_FILE}"
+echo " <Simple>" >> "${TAG_FILE}"
+echo " <Name>DATE_TAGGED</Name>" >> "${TAG_FILE}"
+echo " <String>${DATE}</String>" >> "${TAG_FILE}"
+echo " </Simple>" >> "${TAG_FILE}"
+echo " </Tag>" >> "${TAG_FILE}"
+echo "</Tags>" >> "${TAG_FILE}"
+
+# Add tag info into MKV file
+echo "Adding tag info to ${TITLE} - ${SUBTITLE} ..." >> ${LOGFILE}
+
+/usr/bin/mkvpropedit -r ${LOGFILE} -t all:"${TAG_FILE}" "${TMPFILE}"
+}
+
+clean_up_files()
+# clean up left over files
+{
+unlink ${TMPFILE} 2> /dev/null
+unlink ${TMPCUTFILE} 2> /dev/null
+unlink ${TMPCUTFILE}.map 2> /dev/null
+unlink ${STATUSFILE} 2> /dev/null
+unlink ${IDFILE} 2> /dev/null
+unlink ${HB_RETURN_CODE} 2> /dev/null
+unlink ${TAG_FILE} 2> /dev/null
+}
+
+#-------MAIN SCRIPT------------
+
+# create temp filename so multiple instances won't conflict
+TMPNAME=toX264-$$
+TMPFILE=${TMPDIR}/${TMPNAME}.mkv
+TMPCUTFILE=${TMPDIR}/${TMPNAME}.mpg
+HBINPUTFILE="${1}"
+TITLE="${4}"
+SUBTITLE="${5}"
+JOBID="${6}"
+QUALITY="${7}"
+BASE=`basename ${HBINPUTFILE}`
+HBCLIVER=`pacman -Q | grep handbrake-cli | awk '{ print $NF }' | awk -F"-" '{ print $1 }'`
+STATUSFILE=/tmp/${TMPNAME}-status.log
+HB_RETURN_CODE=/tmp/${TMPNAME}-hb_return_code
+IDFILE=/tmp/${TMPNAME}-id.txt
+TAG_FILE=/tmp/${TMPNAME}.xml
+MYSQLCMD="mysql -B --skip-column-names -u ${DBUserName} -p${DBPassword} -h ${DBHostName} -D ${DBName} -e"
+OAD=`${MYSQLCMD} "select originalairdate from recorded where basename LIKE '${BASE}';"`
+DESCR=`${MYSQLCMD} "select description from recorded where basename LIKE '${BASE}';" | sed 's/\&/and/g'`
+USER=`whoami`
+
+# check if %JOBID% is passed from command line
+if [ -z ${JOBID} ]; then
+ NO_JOBID=1
+else
+ NO_JOBID=0
+fi
+
+# log file location
+CDate="`date`"
+echo "" >> ${LOGFILE}
+echo $CDate >> ${LOGFILE}
+echo "File to encode: ${HBINPUTFILE}" >> ${LOGFILE}
+echo " --> Name: ${TITLE} - ${SUBTITLE}" >> ${LOGFILE}
+echo " --> Temporary Files: ${TMPNAME}.*" >> ${LOGFILE}
+echo "" >> ${LOGFILE}
+
+get_info_for_hb
+ERROR=$?
+
+if [[ ${ERROR} != 0 ]] ; then
+ echo "Error parsing source file information!" >> ${LOGFILE}
+ cat ${IDFILE} >> ${LOGFILE}
+ clean_up_files
+ exit 1
+fi
+
+# start timer
+beforetime="$(date +%s)"
+
+check_myth_jobcmds
+
+# If there is a cutlist, use it:
+if [[ -n `mythutil --getcutlist --chanid "${2}" --starttime "${3}" | grep \
+ Cutlist: | awk -F": " '{ print $NF }'` ]] ; then
+ echo "Applying cutlist for ${TITLE} - ${SUBTITLE} ..." >> ${LOGFILE}
+ mythtranscode --chanid "${2}" --starttime "${3}" -m --honorcutlist \
+ -q --loglevel info --logpath "${LOGPATH}" -o "${TMPCUTFILE}"
+ mythtrans_pid=$!
+ ERROR=$?
+ HBINPUTFILE=${TMPCUTFILE}
+fi
+
+if [[ ${ERROR} != 0 ]] ; then
+ echo "MythTranscode error!" >> ${LOGFILE}
+ echo "Check ${LOGPATH}/mythtranscode.date.${mythtrans_pid}.log for mythtranscode error" >> ${LOGFILE}
+ clean_up_files
+ exit 1
+fi
+
+# run handbrake in background to do conversion
+echo "Encoding ${TITLE} - ${SUBTITLE} ..." >> ${LOGFILE}
+
+( /usr/bin/nice -n19 nohup /usr/bin/HandBrakeCLI -i ${HBINPUTFILE} ${HB_OPTS} \
+ > ${STATUSFILE} 2>&1 ; echo $? > ${HB_RETURN_CODE} ) &
+handbrake_pid=$!
+command_pid=${handbrake_pid}
+get_handbrake_pid
+
+check_background_progress
+
+if [[ `cat ${HB_RETURN_CODE}` != 0 ]] ; then
+ echo "HandBrakeCLI error!" >> ${LOGFILE}
+ cat ${STATUSFILE} >> ${LOGFILE}
+ clean_up_files
+ exit 1
+fi
+
+tag_file
+ERROR=$?
+
+if [[ ${ERROR} != 0 ]] ; then
+ echo "Error creating tag file!" >> ${LOGFILE}
+ cat ${TAG_FILE} >> ${LOGFILE}
+ clean_up_files
+ exit 1
+fi
+
+# make output filename unique and do not clobber an existing file
+# Build a final file name
+FILE=$( echo "${TITLE,,} ${OAD} ${SUBTITLE,,}" | tr -d [:punct:] | tr [:blank:] "_" | tr -s "_" )
+OUTPUTFILE="${OUTDIR}/${FILE}.mkv"
+i=1
+while [ -e "${OUTPUTFILE}" ]
+do
+ OUTPUTFILE="${OUTDIR}/${FILE}-${i}.mkv"
+ i=`expr $i + 1`
+done
+
+# move temp file to output location
+chown -v "${USER}" "${TMPFILE}" >> ${LOGFILE}
+mv -v "${TMPFILE}" "$OUTPUTFILE" >> ${LOGFILE}
+ERROR=$?
+
+if [[ ${ERROR} != 0 ]] ; then
+ echo "Error moving ${TMPFILE} to ${OUTPUTFILE} !" >> ${LOGFILE}
+ clean_up_files
+ exit 1
+fi
+
+# stop timer
+aftertime="$(date +%s)"
+seconds="$(expr ${aftertime} - ${beforetime})"
+
+if [ ${ERROR} -eq 0 ]; then
+ echo "File Encoded Successfully: ${OUTPUTFILE}" >> ${LOGFILE}
+ hours=$((seconds / 3600))
+ seconds=$((seconds % 3600))
+ minutes=$((seconds / 60))
+ seconds=$((seconds % 60))
+ echo "Encoding took ${hours} hour\(s\) ${minutes} minute\(s\) ${seconds} second\(s\) @ ${current_FPS} fps." >> ${LOGFILE}
+ `${MYSQLCMD} "update jobqueue set status = \"272\" where id = \"${JOBID}\";"`
+ update_comment "Encode Successful. Encoding Time: ${hours} hour\(s\) ${minutes} minute\(s\) ${seconds} second\(s\)"
+else
+ echo "ERROR: ${ERROR}" >> ${LOGFILE}
+fi
+
+# Clean up
+clean_up_files
diff --git a/abs/core/LinHES-system/myth2mp3 b/abs/core/LinHES-system/myth2mp3
new file mode 100755
index 0000000..69d5d3f
--- /dev/null
+++ b/abs/core/LinHES-system/myth2mp3
@@ -0,0 +1,96 @@
+#!/bin/sh
+# convert recordings to as mp3 audio only
+# version 1.1.3
+
+# usage:
+# first parameter must be %DIR%/%FILE% of the recording
+# second parameter must be the desired base name of the output
+# third parameter must be %CHANID% if you set USECUTLIST=Y
+# fourth parameter must be %STARTTIME% if you set USECUTLIST=Y
+# In the mythtv setup screen invoke this script like this:
+# MYTHTV User Job Command:
+# /usr/LH/bin/myth2mp3 "%DIR%/%FILE%" "%TITLE% - %SUBTITLE%" "%CHANID%" "%STARTTIME%"
+
+# options:
+BITRATE=256k #ie. 128k, 160k, 192k, 224k, 256k
+USECUTLIST=Y #Y or N
+
+# where the converted audio is stored
+OUT_DIR=/myth/music
+
+# create temp filename so multiple instances won't conflict
+TMPNAME=toMP3-$$
+TMPFILE=/myth/tmp/$TMPNAME
+TMPCUTFILE=/myth/tmp/$TMPNAME.mpg
+FFINPUTFILE=$1
+TITLE=`echo $2 | sed 's/\//_/g'`
+
+# log file location
+LOGFILE=/var/log/mythtv/myth2mp3.log
+CDate="`date`"
+echo "" >> $LOGFILE
+echo $CDate >> $LOGFILE
+echo "File to encode: $1 Name: $TITLE" >> $LOGFILE
+
+# start timer
+beforetime="$(date +%s)"
+
+# check if using cutlist
+if [ $USECUTLIST = Y ];then
+ MYTHCOMMFRAMES=`mythutil --getcutlist --chanid "$3" --starttime "$4" | grep 'Cutlist:' | cut -d \ -f 2`
+ if [ -n "$MYTHCOMMFRAMES" ]; then
+ echo "Extracting Cutlist..." >> $LOGFILE
+ /usr/bin/nice -n19 /usr/bin/mythtranscode --chanid "$3" --starttime "$4" --outfile "$TMPCUTFILE" --mpeg2 --honorcutlist
+ FFINPUTFILE=$TMPCUTFILE
+ fi
+fi
+
+# run ffmpeg to do conversion to wav
+echo "Encoding to intermediate wav..." >> $LOGFILE
+/usr/bin/nice -n19 /usr/bin/ffmpeg -i "$FFINPUTFILE" -vn -acodec pcm_s16le -ar 44100 -ac 2 "$TMPFILE.wav"
+ERROR=$?
+
+# Normalize the intermediate wav
+echo "Normalizing intermediate wav..." >> $LOGFILE
+/usr/bin/nice -n19 /usr/bin/normalize -q "$TMPFILE.wav"
+ERROR=$?
+
+FFINPUTFILE=$TMPFILE.wav
+
+# Final encode of normalized wav to mp3
+echo "Encoding normalized wav to mp3..." >> $LOGFILE
+/usr/bin/nice -n19 /usr/bin/ffmpeg -i "$FFINPUTFILE" -vn -acodec libmp3lame -ab $BITRATE -ar 44100 -ac 2 "$TMPFILE.mp3"
+ERROR=$?
+
+# make output filename unique
+OUTPUTFILE=$OUT_DIR/$TITLE.mp3
+i=1
+while [ -e "$OUTPUTFILE" ]
+do
+ OUTPUTFILE=$OUT_DIR/$TITLE-$i.mp3
+ i=`expr $i + 1`
+done
+
+# move temp file to output location
+chown mythtv "$TMPFILE.mp3" && mv "$TMPFILE.mp3" "$OUTPUTFILE"
+
+# stop timer
+aftertime="$(date +%s)"
+seconds="$(expr $aftertime - $beforetime)"
+
+if [ $ERROR -eq 0 ]; then
+ echo "File Encoded Sucessfully: $OUTPUTFILE" >> $LOGFILE
+ hours=$((seconds / 3600))
+ seconds=$((seconds % 3600))
+ minutes=$((seconds / 60))
+ seconds=$((seconds % 60))
+ echo "Encoding Time: $hours hour(s) $minutes minute(s) $seconds second(s)" >> $LOGFILE
+else
+ echo "ERROR: $ERROR" >> $LOGFILE
+fi
+
+# clean up left over files
+unlink $TMPFILE.mp3 2> /dev/null
+unlink $TMPFILE.wav 2> /dev/null
+unlink $TMPCUTFILE 2> /dev/null
+unlink $TMPCUTFILE.map 2> /dev/null
diff --git a/abs/core/LinHES-system/ripD_eject.sh b/abs/core/LinHES-system/ripD_eject.sh
new file mode 100755
index 0000000..99947a8
--- /dev/null
+++ b/abs/core/LinHES-system/ripD_eject.sh
@@ -0,0 +1,125 @@
+#!/bin/bash
+# /usr/LH/bin/ripD_eject.sh
+# A DVD rip and eject script.
+########################################################################
+DEV='/dev/sr0' # DVD device
+MPNT='media/cdrom' # Mount Point
+Ddir='/myth/video' # DVD output dir List
+Bsnd='/usr/share/sounds/init.wav' # Begin sound file
+Esnd='/usr/share/sounds/complete.wav' # End sound file
+DATE=$(date +%Y%m%d_%H%M) # current date/time
+LOG='/var/log/mythtv/ripD.log' # name of Log file.
+TRACK=$(lsdvd | grep -i longest | awk '{print $3}') #Finds longest track
+FILE=$TITLE
+#-----------------------------------------------------------------------
+FONT="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*"
+OPTS="-f $FONT -s 2 -p bottom -A left -i 50 -l 4"
+#-----------------------------------------------------------------------
+[ -r /etc/rip.cfg ] && . /etc/rip.cfg
+#-----------------------------------------------------------------------
+LOCK=/tmp/.ripLock.$$
+[ "$DISPLAY" == "" ] && export DISPLAY=:0
+########################################################################
+function osd { # $1=text, $2=color, $3=delay
+ cmd="osd_cat $OPTS"
+ [ -n "$2" ] && cmd="$cmd --color=$2"
+ [ -n "$3" ] && cmd="$cmd -d $3"
+ killall osd_cat
+ echo -e "$1" | $cmd
+} >& /dev/null
+function osd_loop() {
+ FN=$1 ; shift
+# TXT="$MAX to $dir"
+ TXT="$MAX to $dir/$FILE"
+ N=0
+ while [ -f "$LOCK" ]; do
+ #osd "\nbacking up DVD: '$@'\n$TXT" gray 60
+ osd "\nbacking up DVD: '$TITLE'\n$TXT" gray 60
+ N=$(($N+1))
+ [ -d "$FN" ] && SIZE=$(du -sh $FN | awk '{print $1}')
+# TXT="$SIZE of $MAX @ $N min. elapsed"
+ TXT="$N min. elapsed"
+ done
+}
+########################################################################
+LinHES-osd "\nDetecting DVD" gray20 5 &
+echo "`date` detected DVD" >> $LOG
+rm -f /tmp/.ripLock.*
+#=======================================================================
+for dir in $Ddir ; do
+ if [ -d $dir -a -w $dir ]; then
+ break
+ fi
+done
+#-----------------------------------------------------------------------
+if [ ! -d "$dir" ]; then
+ echo "no $dir" >> $LOG
+ osd "\ndirectory: $dir\nnot found!" red 10 &
+ eject ; eject
+ exit 0
+fi
+if [ ! -w "$dir" ]; then
+ echo "$dir not writable" >> $LOG
+ osd "\ndirectory: $Cdir\nnot writable!" red 10 &
+ eject ; eject
+ exit 0
+fi
+#-----------------------------------------------------------------------
+mount $DEV >& /dev/null
+dev=$(readlink $DEV)
+df=$(df -h /dev/$dev | grep /dev/$dev)
+MAX=$(echo $df | while read d v r ; do echo $v ; done)
+echo " backup $MAX to $dir" >> $LOG
+#=======================================================================
+# first make sure DMA is on:
+sudo hdparm -d1 -u1 $DEV >& /dev/null
+# attempt to get the DVD information:
+TITLE=$(dvdbackup -i /dev/sr0 -I | grep information | awk '{ s = ""; for (i = 8; i <= NF; i++) s = s $i " "; print s }' | tr -d '"' | sed 's/ /_/g' | sed 's/_$//g')
+if [ "$TITLE" == "DVD_VIDEO" -o "$TITLE" == "" \
+ -o "$TITLE" == " " -o "$TITLE" == "[ ].*" ]; then
+ # if not a good title,
+ TITLE="dvdbackup_$DATE"
+fi
+echo " $TITLE" >> $LOG
+if [ $1 = m ]
+then
+ COMMAND="dvdbackup -M -i $DEV -o $dir -n $TITLE"
+ elif [ $1 = h ]
+ then
+# COMMAND="mencoder dvd://$TRACK -alang en -oac mp3lame -lameopts br=320:cbr -ovc lavc -lavcopts vcodec=mpeg4:vhq -vf scale -zoom -xy 720 -o $dir/$TITLE.avi"
+ COMMAND="HandBrakeCLI -i $DEV -o $dir/$TITLE.mp4 --preset "High\ Profile" --main-feature"
+ FILE=$TITLE.mp4
+ elif [ $1 = n ]
+ then
+# COMMAND="mencoder dvd://$TRACK -alang en -oac mp3lame -lameopts br=160:cbr -ovc lavc -lavcopts vcodec=mpeg4:vhq -vf scale -zoom -xy 512 -o $dir/$TITLE.avi"
+ COMMAND="HandBrakeCLI -i $DEV -o $dir/$TITLE.mp4 --preset "Normal" --main-feature"
+ FILE=$TITLE.mp4
+ elif [ $1 = l ]
+ then
+# COMMAND="mencoder dvd://$TRACK -alang en -oac mp3lame -lameopts br=96:cbr -ovc lavc -lavcopts vcodec=mpeg4:vhq -vf scale -zoom -xy 320 -o $dir/$TITLE.avi"
+ COMMAND="HandBrakeCLI -i $DEV -o $dir/$TITLE.mp4 --preset "Classic" --main-feature"
+ FILE=$TITLE.mp4
+ elif [ $1 = i ]
+ then
+ COMMAND="dd if=$DEV of=$dir/$TITLE.iso bs=2048"
+ FILE=$TITLE.iso
+fi
+{ # for the redir below:
+ # Begin:
+ touch $LOCK
+ osd_loop "$dir/$TITLE" "$TITLE" &
+ dvdbackup -i $DEV -I
+ sleep 1 ; aplay $Bsnd
+ $COMMAND
+ # Finish:
+ rm -f $LOCK
+ osd "\nfinish DVD: '$TITLE'\ninto $dir/$FILE" gray20 5 &
+ sleep 1 ; aplay $Esnd
+ # Eject the media:
+ sudo eject ; sudo eject
+} > $dir/.$TITLE.log 2>&1
+echo " `du -sh $dir/$FILE`" >> $LOG
+echo " `date` finished DVD" >> $LOG
+exit 0
+########################################################################
+# End