#!/bin/bash
function show_help {
echo "Usage: $0 -g GO [-v verbose] [-h help] [-c CRF=26 ] [-d duration=3600 ] [-f output_file=capture_] [ -i DeviceID=101176E2 ] [ -n Channel=19 ] [ -o output_dest=/mnt/BigUSBDisk/movies/TV_VARIOUS ] [ -p program=0 ] [ -t title=capture_ ] [ -u tuner=0 ] [ -y delay (secs) to start] ]" >&2
exit 1
}
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize our own variables:
output_dest=/mnt/BigUSBDisk/movies/TV_VARIOUS
output_file=capture_
verbose=0
CRF=26
channel=19
program=0
duration=36
title=SM_capture_
deviceID=101176E2
tunerID=0
startDelay=0
while getopts "h?c:e:d:f:i:n:o:p:t:u:y:" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
v) verbose=1
;;
c) CRF=$OPTARG
;;
d) duration=$OPTARG
;;
f) output_file=$OPTARG
;;
i) deviceID=$OPTARG
;;
n) channel=$OPTARG
;;
o) output_dest=$OPTARG
;;
p) program=$OPTARG
;;
t) title=$OPTARG
;;
u) tunerID=$OPTARG
;;
y) startDelay=$OPTARG
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
RN=${RANDOM}
FN=${output_dest}/${output_file}${RN}.mpg
SN=${output_dest}/${title}${RN}.mpg
SN=/mnt/BigUSBDisk/movies/TV_VARIOUS/SM_capture_${RN}.mpg
echo Capture Channel $channel , program $program
echo Capture for $duration seconds to $FN
echo then convert to $SN
echo Delaying $startDelay seconds
sleep $startDelay
echo Delay Done!! Starting......
hdhomerun_config $deviceID set /tuner0/channel auto:$channel
hdhomerun_config $deviceID set /tuner0/program $program
rm $FN
hdhomerun_config $deviceID save /tuner0 $FN & export APP_PID=$!
echo Started in Background with process ID $APP_PID
sleep $duration
echo Done capturing...Killing the capture process now!!!
kill -9 $APP_PID
echo Killed!!!
avconv -i ${FN} -vf scale=iw*.75:ih*.75 -v quiet -preset medium $SN
Last active
September 18, 2017 01:53
-
-
Save erikson1970/21549c6787f621558dca64c735542261 to your computer and use it in GitHub Desktop.
Record a program using HDHomerun
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment