-
Notifications
You must be signed in to change notification settings - Fork 0
/
record
executable file
·83 lines (69 loc) · 1.62 KB
/
record
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
if [ -e /tv/killswitch ]
then
echo "Kill switch engaged, exiting..."
exit
fi
LOG_DIR=/dev/null
MOVIES_DIR=`pwd`
STEAL=false
CC=false
CHANNEL=false
TIME=false
TITLE=false
if [ -e /etc/record.conf ]
then
echo "/etc/record.conf found, sourcing..."
source /etc/record.conf
fi
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-s|--steal)
STEAL=true
shift
;;
-c|--closed-captions)
CC=true
shift
;;
*)
if [ $CHANNEL = false ]
then
CHANNEL="$1"
elif [ $TIME = false ]
then
TIME="$1"
elif [ $TITLE = false ]
then
TITLE="$1"
else
echo 'Too many arguments, exiting...'
exit 1
fi
shift
;;
esac
done
if ([ $CHANNEL = false ] || [ $TIME = false ] || [ $TITLE = false ])
then
echo 'Not enough arguments, exiting...'
exit 1
fi
if [ $STEAL = true ]
then
echo 'Stealing...';
pkill mplayer
fi
if [ -e "$MOVIES_DIR/$TITLE.ts" ]
then
rm "$MOVIES_DIR/$TITLE.ts"
fi
timeout --foreground -s STOP -k 5s $TIME mplayer -dumpstream -dumpfile "$MOVIES_DIR/$TITLE.ts" dvb://$CHANNEL |& tee "$LOG_DIR/${TITLE}_record"
sleep 5s
avconv -y -i "$MOVIES_DIR/$TITLE.ts" -vcodec h264 -acodec aac -strict -2 "$MOVIES_DIR/$TITLE.mp4" |& tee "$LOG_DIR/${TITLE}_avconv"
if [ $CC = true ]
then
ffmpeg -y -f lavfi -i "movie=$MOVIES_DIR/$TITLE.ts[out+subcc]" "$MOVIES_DIR/${TITLE}_cc.srt" 2>&1 | tee "$LOG_DIR/${TITLE}_ffmpeg"
fi