Skip to content
CHEF-KOCH edited this page Mar 6, 2019 · 10 revisions

Overview

Comskip is a commercial detector. It is a console application that reads a mpeg or h.264 file and analyses the content based on a large amount of configurable parameters. After analysis, it generates a file in various possible formats containing the location of the commercials inside the video file. The formats include input files for interactive video editors (VideoRedo, Cuttermaran,Mpeg2Schnitt...) command line video cutters (mpgtx, cuttermaran, mencoder) and video players (zoomplayer, mplayer, etc.). Comskip can read MPEG PS, TS, DVR-MS and WTV files up to HD resolution (max 2000x1200) at various framerates (PAL and NTSC). Comskip can NOT read copy protected recordings.

Synology package installation

After installation you can launch it from the command line like this:

comskip /volume1/@appstore/comskip/bin/comskip.ini "path to your video file"

At this point, the default configuration will be used located at /volume1/@appstore/comskip/bin/comskip.ini After Comskip has finished you should test if it detects the commercial brakes correctly and when needed make adjustments to the config (comskip.ini). A more optimized comskip.ini can be found here (pastebin.com).

More information about configuring Comskip can be found here (pastebin.com).

Post-processing using TVHeadend

Comskip is an excellent tool to use in combination with TVHeadend for post-processing a recording. To do this you need to create a shell script that looks something like this. You should change the following to fit your needs!

  • COMSKIPPATH="/volume1/@appstore/comskip/bin/comskip"
  • COMSKIPINI="/volume1/@appstore/comskip/var/comskip.ini"
  • COMSKIPLOGS="/volumeUSB1/usbshare/logs/comskip"
  • TVHEADENDPP="/volumeUSB1/usbshare/logs/tvheadend"

tvheadend-pp.sh (see below)

#!/bin/sh
 
INPUTVIDEO="$1"  # Full path to recording, i.e. /home/user/Videos/News.ts
 
BASENAME=`/usr/bin/basename $INPUTVIDEO .mkv`
 
DIRNAME=`/usr/bin/dirname $INPUTVIDEO`
EDLFILE="$DIRNAME/$BASENAME.edl"
LOGFILE="$DIRNAME/$BASENAME.log"
TXTFILE="$DIRNAME/$BASENAME.txt"
LOGOFILE="$DIRNAME/$BASENAME.logo.txt"
COMSKIPPATH="/volume1/@appstore/comskip/bin/comskip"
COMSKIPINI="/volume1/@appstore/comskip/var/comskip.ini"
COMSKIPLOGS="/volumeUSB1/usbshare/logs/comskip"
TVHEADENDPP="/volumeUSB1/usbshare/logs/tvheadend"
 
CreateLog(){
    echo "***** CREATE LOG *****" >> ${TVHEADENDPP}/tvheadendpp$$.log
    echo "*****" > ${TVHEADENDPP}/tvheadendpp$$.log
    echo "***** INPUT = $INPUTVIDEO *****" >> ${TVHEADENDPP}/tvheadendpp$$.log
    echo "*****" >> ${TVHEADENDPP}/tvheadendpp$$.log
}
 
FlagCommercials(){
    echo "Starting Commercial Flagging" >> ${TVHEADENDPP}/tvheadendpp$$.log
    echo "*****" >> ${TVHEADENDPP}/tvheadendpp$$.log
    echo "***** OUTPUT = "$EDLFILE" *****" >> ${TVHEADENDPP}/tvheadendpp$$.log
    echo "*****" >> ${TVHEADENDPP}/tvheadendpp$$.log
    /usr/bin/whoami >> ${TVHEADENDPP}/tvheadendpp$$.log    # for debugging purposes, who is running this script?
    echo "Started at `/bin/date`" >> ${TVHEADENDPP}/tvheadendpp$$.log
    echo "*****" >> ${TVHEADENDPP}/tvheadendpp$$.log
    echo "*****" >> ${TVHEADENDPP}/tvheadendpp$$.log
 
    $COMSKIPPATH --ini=$COMSKIPINI $INPUTVIDEO 2>&1 </dev/null >> ${TVHEADENDPP}/tvheadendpp$$.log
 
    echo "*****" >> ${TVHEADENDPP}/tvheadendpp$$.log
    echo "*****" >> ${TVHEADENDPP}/tvheadendpp$$.log
 
    echo "EDL for $INPUTVIDEO:" >> ${TVHEADENDPP}/tvheadendpp$$.log
}
 
CleanUp(){
    echo "***** CLEAN UP *****" >> ${TVHEADENDPP}/tvheadendpp$$.log
    echo "[[ ! -f $LOGFILE ]] || /bin/mv $LOGFILE $COMSKIPLOGS"
    echo "[[ ! -f $TXTFILE ]] || /bin/mv $TXTFILE $COMSKIPLOGS"
    /bin/mv $LOGFILE $COMSKIPLOGS
    /bin/mv $TXTFILE $COMSKIPLOGS
}      
 
CreateLog
FlagCommercials
CleanUp
 
echo "Finished at `/bin/date`" >> ${TVHEADENDPP}/tvheadendpp$$.log

Use /path/to/script.sh %f in your post-processing recording settings in TVHeadend to make it active.

Sources:

Clone this wiki locally