-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomcut-bak
96 lines (74 loc) · 2.89 KB
/
comcut-bak
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
84
85
86
87
88
89
90
91
#!/usr/bin/bash
CSDIR=$(dirname $0)
TMPDIR="/volume1/media/tmp/$2"
EMBYUSER="emby"
EMBYGROUP="users"
mkdir ${TMPDIR}
lockfile="${TMPDIR}/post.lock"
while [ -f "$lockfile" ]; do
echo "Waiting"
sleep 5
done
touch "$lockfile"
infile=$1
outfile="$infile"
show=`basename "$infile"`
edlfile="${TMPDIR}/${show%.*}.edl"
logfile="${TMPDIR}/${show%.*}.log"
logofile="${TMPDIR}/${show%.*}.logo.txt"
txtfile="${TMPDIR}/${show%.*}.txt"
## I have no idea where this VPrj file is getting created
vprjfile="${TMPDIR}/${show%.*}.VPrj"
showfile="${TMPDIR}/${show%.*}_a.txt"
chapterfile=""
final="${infile%.*}.mkv"
i=0
start=0
hascommercials=false
writefiles()
{
printf "file '%s'\n" "$chapterfile" >> "$showfile"
duration=`echo "$end" "$start" | awk '{printf "%f", $1 - $2}'`
/volume1/@appstore/ffmpeg/bin/ffmpeg -hide_banner -loglevel error -nostdin -i "$infile" -ss $start -t $duration -c copy -y "$chapterfile"
}
${CSDIR}/comskip --output=${TMPDIR} --ini=${CSDIR}/../var/comskip.ini "$infile"
while IFS=$'\t\n' read -r end startnext c _;
do
if [ `echo "$end" | awk '{printf "%i", $0 * 1000}'` -gt `echo "$start" | awk '{printf "%i", $0 * 1000}'` ]
then
i=$((i + 1))
hascommercials=true
chapterfile=${TMPDIR}/part-$i.ts
writefiles $end $start $i "$chapterfile" "$showfile" "$infile"
fi
start=$startnext
done < "$edlfile"
#dont forget to add the final part from last commercial to end of file
if [ $hascommercials=true ]
then
end=`/volume1/@appstore/ffmpeg/bin/ffmpeg -hide_banner -nostdin -i "$infile" 2>&1 | grep Duration | awk '{print $2}' | tr -d , | awk -F: '{ printf "%f", ($1*3600)+($2*60)+$3 }'`
if [ `echo "$end" | awk '{printf "%i", $0 * 1000}'` -gt `echo "$start" | awk '{printf "%i", $0 * 1000}'` ]
then
i=$((i + 1))
chapterfile=${TMPDIR}/part-$i.ts
writefiles $end $start $i "$chapterfile" "$showfile" "$infile"
fi
fi
/volume1/@appstore/ffmpeg/bin/ffmpeg -hide_banner -loglevel error -nostdin -f concat -safe 0 -i "$showfile" -c copy -y "$outfile"
/volume1/@appstore/ffmpeg/bin/ffmpeg -i "$outfile" -vf yadif -c:v libx264 -preset ultrafast -crf 18 -max_muxing_queue_size 1024 -c:a copy "$final"
#/usr/local/ffmpeg/bin/ffmpeg -hide_banner -loglevel error -nostdin -f concat -safe 0 -i "$showfile" -c copy -y "$outfile"
#/usr/local/ffmpeg/bin/ffmpeg -i "$outfile" -vf yadif -c:v libx264 -preset ultrafast -crf 18 -max_muxing_queue_size 1024 -c:a copy "$final"
#/usr/local/ffmpeg/bin/ffmpeg -i "$outfile" -vf yadif -c:v libx264 -preset ultrafast -s 1280x720 -crf 18 -max_muxing_queue_size 1024 -c:a copy "$final"
#/usr/local/ffmpeg/bin/ffmpeg -i "$outfile" -vf yadif -c:v libx264 -preset slow -crf 18 -max_muxing_queue_size 1024 -c:a copy "$final"
rm "$edlfile"
rm "$logfile"
#rm "$logofile"
#rm "$txtfile"
#rm "$vprjfile"
#rm "$showfile"
#rm "$lockfile"
#rm -f ${TMPDIR}/part-*.ts
#rm -Rf ${TMPDIR}
#rm -f "$1"
chown ${EMBYUSER} "$final"
chgrp ${EMBYGROUP} "$final"