Project

General

Profile

Post Processing Scripts ยป postprocess.sh

Bob Lightfoot, 2015-01-12 03:43

 
1
#!/bin/sh
2

    
3
# variables
4
TSVIDEO=$1    #Full path to recording               /video/Recordings/%{ShowName}/%{FileName.ext}
5
basename=$2   #Basename of recording                FileName.ext
6
error=$3      #error from tvheadend recorder        "OK" if no error
7
command=$4    #Type of Post Processing to do        comskip  or compact 
8
compactbase=$(echo "$basename" | sed "s/...$//")    # Remove file ext (3 char)
9

    
10
# exit if not ok
11
if [ $error != "OK" ]; then
12
   echo " Not OK"
13
   exit 1
14
fi
15

    
16
# Determine Length of Pathname & Filename
17
TS=${#TSVIDEO}
18
# echo $TS
19

    
20
# Determine Length of the Filename Only
21
base=${#basename}
22
# echo $base
23

    
24
# Calcualte the difference between filename and full path length
25
let TSPATHlen=$TS-$base
26
# echo $TSPATHlen
27

    
28
# Strip Filename down to Filepath
29
TSPATH="${TSVIDEO:0:$TSPATHlen}"
30

    
31
# Debug Outputs for testing script works
32
# echo " Original Full File Name "
33
# echo $TSVIDEO
34

    
35
# echo " Stripped Down Path "
36
# echo $TSPATH
37

    
38
# Check if command is comskip and then issue comskip command
39
if [ $command = "comskip" ]; then
40
	/usr/bin/comskip -t -d 13 $TSVIDEO $TSPATH
41
	exit 0
42
fi
43

    
44
# Check if command is compact and then issue proper ffmpeg command
45
if [ $command = "compact" ]; then
46
  	COMPACTVIDEO="/video/videos/$compactbase.mp4"
47
	/usr/bin/ffmpeg -i $TSVIDEO -vcodec h264 -acodec mp3 -crf 30 $COMPACTVIDEO
48
	exit 0
49
fi
50

    
51
if [ $command = "" ]; then
52
	/usr/bin/comskip -t -d 13 $TSVIDEO $TSPATH
53
	exit 0
54
fi
55

    
    (1-1/1)