1 | #!/bin/bash |
---|
2 | # add this to recording started event |
---|
3 | # /home/peter/proj/import_test/bin/import_rec_start.sh %FILE% %CHANID% %CARDID% %ENDTIMEISO% & |
---|
4 | exec 1>>/home/peter/proj/import_test/log/import_rec_start.log |
---|
5 | exec 2>&1 |
---|
6 | date |
---|
7 | echo input parameters are $1 $2 $3 $4 |
---|
8 | set -x |
---|
9 | file="$1" |
---|
10 | chanid=$2 |
---|
11 | cardid=$3 |
---|
12 | endtime=$4 |
---|
13 | # This needs to be changed to a process that will get the real |
---|
14 | # file name, You could have multiple storage groups, so assuming |
---|
15 | # one directory is not acceptable |
---|
16 | storage_dir=/home/peter/data/mythtv-build/storage |
---|
17 | fullfile="$storage_dir/$file" |
---|
18 | # The card id and channel need to be checked against mythtv rather |
---|
19 | # than hard code here. some mapping to the channels.conf is needed. |
---|
20 | # There will normally be more than 2 channels. |
---|
21 | if [[ "$cardid" == 38 ]] ; then |
---|
22 | if [[ "$chanid" == 13587 ]] ; then |
---|
23 | channame=IONLife |
---|
24 | elif [[ "$chanid" == 13582 ]] ; then |
---|
25 | channame=ION |
---|
26 | fi |
---|
27 | if [[ "$channame" != "" ]] ; then |
---|
28 | azap -c /home/peter/proj/import_test/dvb/channels.conf -r $channame & |
---|
29 | azap_pid=$! |
---|
30 | ffmpeg -i /dev/dvb/adapter0/dvr0 -y -acodec copy -vcodec copy -scodec copy -f mpegts "$fullfile" & |
---|
31 | ffmpeg_pid=$! |
---|
32 | # Calculation of recording duration. The recording is stopped |
---|
33 | # by a sleep timer and a kill command. Another option would |
---|
34 | # be to set a parameter in ffmpeg of the encoding start and end time |
---|
35 | # and let it automatically end after it sees the appropriate |
---|
36 | # quantity of video. |
---|
37 | end=`date -d $endtime +%s` |
---|
38 | now=`date +%s` |
---|
39 | let duration=end-now |
---|
40 | sleep $duration |
---|
41 | kill $azap_pid $ffmpeg_pid |
---|
42 | fi |
---|
43 | fi |
---|
44 | |
---|
45 | # echo azap_pid=$azap_pid > /home/peter/proj/import_test/log/pids_$file |
---|
46 | # echo ffmpeg_pid=$ffmpeg_pid >> /home/peter/proj/import_test/log/pids_$file |
---|