Is the above possible using the default built in commercial detection and a custom comskip.ini file?
Or is it only possible to actually delete the commercials?
I don’t really want to go back down the MCEBuddy, Comskip post processing script route.
Is the above possible using the default built in commercial detection and a custom comskip.ini file?
Or is it only possible to actually delete the commercials?
I don’t really want to go back down the MCEBuddy, Comskip post processing script route.
It will only cut the commercials.
Why don’t you want to go with mcebuddy if you are running Windows and are able to? I have been running mcebuddy as part of my Post processing for 18 months with no issues other than an occasional show that does not go through the post processing but that only happens when I have 4 or more shows all ending at the same time.
I don’t know really! I suppose because I remember taking a lot of time setting it all up when I first started using it.
What are the best MCEBuddy settings to use then for Plex? I seem to remember it having a whole stack of options!
I have a comskip.ini suitable for the UK I think, although I just tested it on a recording and it cut off the very beginning of the programme.
MCEBuddy does have a lot of options but once you have it setup I haven’t modified my settings in well over a year. The last changes I made was breaking up different shows based on show title and doing different processing based on the show. For example, News shows versus The Big Bang Theory, versus other shows. If you have a good comskip.ini file and you already have the bat file posted by another Plex user online you just configure mcebuddy for the profile you want point it to the comskip.ini file and add the bat file path/filename to the DVR setup. You can also setup mcebuddy to monitor your recording folder and not do the post processing. There is a decent guide on Reddit written by the author of the post processing bat file.
Thanks, I’ve just been working my way through that guide!
Now to test…
Though this is an old post, it has been invaluable for me in gathering the appropriate tools to achieve this. I find the commercial detection a little innacurate at times, and I’m far happier with chapters set into the file by postprocessing than the destructive nature of the built-in commercial removal. This is how I’ve done it (note, my architecture is Linux- specifically Debian stretch).
apt-get update && apt-get install ffmpeg
Google taught me all I know about bash scripting. Please don’t judge!
$ cat ~/src/comskip2ffmpeg
#!/bin/bash
chapter=1
start=1
function assistance()
{
>&2 echo "usage: $0 framerate totalframes"
>&2 echo " framerate: this is expected in the format that ffprobe delivers, for example 25fps is coded as 25/1, 23.97 is coded as 24000/1001"
>&2 echo " e.g. ffprobe -v 0 -of csv=p=0 -select_streams 0 -show_entries stream=r_frame_rate infile"
>&2 echo " totalframes: this is the total number of frames in the video file"
>&2 echo " e.g. ffprobe -v 0 -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 infile"
exit
}
if [[ "$1" =~ ^([0-9]+)\/([0-9]+)$ ]]
then
framerate="${BASH_REMATCH[2]}/${BASH_REMATCH[1]}"
else
assistance
fi
if [[ "$2" =~ ^([0-9]+)$ ]]
then
end=$2
else
assistance
fi
echo ";FFMETADATA1"
while read line
do
if [[ $line =~ ^([0-9]+)[[:space:]]([0-9]+)$ ]]
then
if [ $start -gt 50 ] # Ignore commercial start/end markers in the first 2s of play
then
echo "[CHAPTER]"
echo "TIMEBASE=$framerate"
echo "START=$start"
echo "END=${BASH_REMATCH[1]}"
echo "TITLE=Chapter $chapter"
fi
if [ ${BASH_REMATCH[1]} -gt 50 ] # Ignore commercial start/end markers in the first 2s of play
then
echo "[CHAPTER]"
echo "TIMEBASE=$framerate"
echo "START=${BASH_REMATCH[1]}"
echo "END=${BASH_REMATCH[2]}"
echo "TITLE=Commercials $((chapter++))"
fi
start=${BASH_REMATCH[2]}
fi
done
if [ $(( $end - $start )) -gt 150 ] # Ignore commercial start/end markers in the last 1m of play
then
echo "[CHAPTER]"
echo "TIMEBASE $framerate"
echo "START=$start"
echo "END=$end"
echo "TITLE=Chapter $chapter"
fi
$ cat ~/src/postprocesstv
#!/bin/bash
function assistance ()
{
>&2 echo "Usage: $0 inputfile"
exit
}
if [ -f "$1" ]
then
infile="$1"
else
assistance
fi
# get framerate
framerate=$(/usr/bin/ffprobe -v 0 -of csv=p=0 -select_streams 0 -show_entries stream=r_frame_rate "$infile" | head -1)
# get total frames
totalframes=$(/usr/bin/ffprobe -v 0 -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 "$infile" | head -1)
# detect commercials
> /dev/null 2>&1 /usr/local/bin/comskip -q --output=/tmp/ --output-filename=postprocesstv "$infile"
# create metadata
/root/src/comskip2ffmpeg $framerate $totalframes < /tmp/postprocesstv.txt > /tmp/postprocesstv.ffmetadata
# recode ts file
/usr/bin/ffmpeg -v 0 -i "$infile" -i /tmp/postprocesstv.ffmetadata -map_metadata 1 -codec copy "$infile.mkv"