Hey folks i want to say thanks for this forum and thank you for this guide.
I have the postproccessing script working when I run the script manually as root on a file >> ./post.sh /path/to/file
The script im using uses comskip to cut commercials, ccextrator to rip the cc to srt, then FFMPEg to encode to mkv...
But when Plex records, script runs, cuts the commercials but does not rip the cc or encode not sure why.
Here is the post script i run:
Code:
#!/bin/csh
set path = ($path /usr/local/bin)
set lockFile = '/tmp/dvrProcessing.lock'
set origFile = "$1"
set tmpEncode = "$1.mkv"
set dvrPostLog = '/mnt/media/dvrProcessing.log'
set tmpSrt = "English.srt"
set NAME = `echo $tmpEncode | cut -f 1,3 -d'.'`
#Wait if post processing is already running
while ( -f $lockFile )
echo "`date '+%Y-%m-%d %H:%M:%S'` - '$lockFile' exists, sleeping processing of '$origFile'" | tee $dvrPostLog
sleep 10
end
#Create lock file to prevent other post-processing from running simultaneously
echo "`date '+%Y-%m-%d %H:%M:%S'` - Creating lock file for processing '$origFile'" | tee -a $dvrPostLog
touch $lockFile
#Mark and cut commercials ; be sure to spcify each directory below
echo "`date '+%Y-%m-%d %H:%M:%S'` - Mark and cut commercials from '$origFile'" | tee -a $dvrPostLog
/comchap/comcut --ffmpeg=/usr/local/bin/ffmpeg --lockfile=/tmp/comchap.lock --comskip-ini=/comskiplinux/Comskip-master/comskip.ini --comskip=/comskiplinux/Comskip-master/comskip "$origFile"
#Pull CC from file to SRT file
echo "`date '+%Y-%m-%d %H:%M:%S'` - Pulling Closed captions from '$origFile' to SRT file" | tee -a $dvrPostLog
/ccextractor/build/ccextractor "$origFile" -o "$tmpSrt"
#Encode file to H.265 with mkv container using ffmpeg
echo "`date '+%Y-%m-%d %H:%M:%S'` - Re-encoding '$origFile' to MKV file while adding cc data" | tee -a $dvrPostLog
/usr/local/bin/ffmpeg -i "$origFile" -i "$tmpSrt" -map 0 -map 1 -acodec copy -scodec copy -c:v libx264 -preset veryfast -crf 18 -profile:v high -level 4.2 -vf yadif "$tmpEncode"
#Remove SRT file
echo "`date '+%Y-%m-%d %H:%M:%S'` - Remove SRT file" | tee -a $dvrPostLog
rm -f "$tmpSrt"
#Remove the .ts from file name
echo "`date '+%Y-%m-%d %H:%M:%S'` - Removing .ts from file name" | tee -a $dvrPostLog
mv -f "$tmpEncode" "$NAME"
#Remove original ts file
echo "`date '+%Y-%m-%d %H:%M:%S'` - Deleting '$origFile'" | tee -a $dvrPostLog
mv -f "$origFile" /tmp/videos/
#Remove lock file
echo "`date '+%Y-%m-%d %H:%M:%S'` - Done processing '$origFile' removing lock" | tee -a $dvrPostLog
rm $lockFile
exit 0
Thanks to the members here and in the emby forums I was able to edit the script to make it more to my linking i had no clue what i was doing so the scripts here and google helped me put this together.
I added the timestamp to the log file so I can see how long it would take to encode etc. I used
Code:
set NAME = `echo $tmpEncode | cut -f 1,3 -d'.'`
to rename the filename.ts.mkv to filename.mkv it works not sure if it the right way but it worked for me.
I think it may be permissions that is why the script only runs up to commercial cut. I never had to do anything to give plex user permissions to run comskip, comcut etc. So not really sure what is going on.
Any help is appreciated thank you.