#Please see the Github repository for Comchap and Comcut
This thread got more attention than I originally intended. Feel free to read this entire thread for discussions about the Comchap and Comcut scripts.
Summary:
Comchap and comcut are two bash scripts developed for automating the detection of commercials in recorded video files using Comskip. Both scripts are very similar to one another, but offer different uses.
Comchap - Calls Comskip on a specified file to detect commercials writing the results to a file. The file is then read by Comchap to add chapters into the original file marking where the commercials were detected. The commercials are not removed from the resulting video.
Comcut - Like Comchap, it calls Comskip to detect commercials. Comcut then creates a new file using the source file, but with the commercials cut out. Chapters are still added to the resulting file for convenience to the viewer. By default, the source file will be overwritten by the resulting file.
Neither Comchap nor Comcut do any transcoding of the source file. That is considered to be outside of scope of either tool.
Both scripts were developed to be used as standalone tools without regards to Plex. However, if no command line arguments are needed for your environment, both may be used directly as a post processing script within Plex.
The latest/greatest script can always be found on Github.
I’ve wrote a small bash script which relies on Comskip to generate an EDL file. It then takes the EDL file and to generate a metadata file that ffmpeg can use to import chapter information. The script then uses ffmpeg to create a new file with chapter information included. Once done it replaces the old file with the new file.
The problem I’m seeing is with Plex seeing the new file and re-matching it within the library and often matching with the wrong show (specifically NFL football). Is there some trick that would preserve any metadata with the original file that I’m not aware of?
It simply adds chapter data and not remove the commercials in case the commercial detection is wrong.
BTW, this is working on my Arch Linux box using comskip from AUR.
Edit: I removed the link to pastebin and replaced it with the github link to avoid confusion
It turns out ffmpeg seems to have a problem with the LD_LIBRARY_PATH environment variable being set. I’ve updated my script to unset LD_LIBRARY_PATH and re-set it once done.
This script should be able to be used directly in the postprocessingScript setting.
curl -X PUT "http://localhost:32400/livetv/dvrs/X/prefs?postprocessingScript=/path/to/comchap"
I intend on making a command line argument that could be passed to Comchap that would remove commercials completely instead of just adding chapters.
In fact this script was originally inspired by https://hackmemory.wordpress.com/2013/04/08/lightning-fast-video-splitting-script/. That script takes an EDL file and creates multiple temporary files then joins the files back together in a single file (with the commercials removed). I had issues with it and it evolved into what I posted.
I’m not sure if/when I’d get to modifying the script to do commercial removal though. Feel free to fork the github project and give it a shot yourself.
Thank you for this, it was exactly what I was looking for, I had run into Compskip before but I only found the websites that said it was for Windows, and as a MacOS/Linux exclusive house that wouldn’t really work for me. Now my question is how do you add this to the DVR workflow? do you just run it manually at this point or do you have a way of automating the process?
@jonathanderry said:
Thank you for this, it was exactly what I was looking for, I had run into Compskip before but I only found the websites that said it was for Windows, and as a MacOS/Linux exclusive house that wouldn’t really work for me. Now my question is how do you add this to the DVR workflow? do you just run it manually at this point or do you have a way of automating the process?
Could somebody assist me in directions on how to install comskip on a headless ubuntu server 16.04 LTS? I tried following directions on the github page but am not to familiar with compiling software. I completed
$ git clone git://github.com/erikkaashoek/Comskip
$ cd Comskip
$ ./autogen.sh
$ ./configure
$ make
the above appeared to complete without errors. What happens from there?
also I am new to scripting so a tutorial would be great on how to put this all together in linux…
@saf1 said:
Not had a chance to try it, but does it just do chapters so you skip forward or does it actually remove commercials?
Also, how fast is it or how long does it take to convert a typical 30 minute to 1 hour show?
Thanks.
No, it does not remove commercials (yet). It merely adds chapter information so you can easily skip them.
The longest part is doing the commerical detection part with Comskip. I’m my testing of ~3hr NFL games recordings it would take about 5 minutes. My box is just a core i5, so your mileage may vary here.
It actually makes a new mkv (or whatever) file copying the audio and video codecs from the source file then replaces the old file with the new. This only takes a few seconds.
So for a 3 hour recording everything is done in about 5 minutes total.
export PKG_CONFIG_PATH=/opt/ffmpeg/lib/pkgconfig before the ./autogen.sh when installing Comskip otherwise it couldn’t complete the installation of comskip.
Thank you i will try that. I did not put install at the end. Another stupid question. Will it automatically skip through the comercials on playback then? I use android client and chromecasts mostly
@pbenzschawel every client i’ve tried supports chapters. It won’t skip them automatically - you’ll just need to skip to the next chapter when commercials start. The example in that thread creates a chapter at the end of each commercial break.