“Commercial Clapper” script

Tvheadend Post Processing with Commercial Removal, Transcoding, & Plex/Kodi Naming Convention

hblogo tvhlogoraspberryPi

Bash Script is located here:

movie-clapboard

Commercial Clapboard

(A name was required to open a github repo. This is the best I could do.)

“Putting the Clap-Chop on Slap-Chop”

https://github.com/andyrblank/Commercial-Clapboard

Requires:

This is a post processing BASH / Shell script designed for use with Tvheadend (tvheadend.org) to scan for commercials, transcode to H264 & cut commercials from the H264 file. The script also uses the xmltv output of mc2xml to name recordings for Plex/Kodi(XBMC) to scrape properly.

Future Goals of this Project are:

So I’ve had some personal requirements changes. One of the problems with the way this is written is that it fires off post processing immediately regardless if one is already processing. This works for the first few but after 3 or 4 are processing at once recordings start to suffer pixelation and processing speed is brought down to a crawl. Not to mention that even with one running my Plex server is unable to transcode files for remote play anymore. So here’s how I’m thinking about solving these problems:

  1. Build a queuing system and only post-process one at a time.
  2. Implement a SQL database for the Queue and to replace logging.
  3. Run post processing on a separate system (I’m going to try using my Raspberry Pi)

Challenges

  • As amazing, fun and power efficient as the Raspberry Pi is… ┬áthe CPU is slow… even overclocked… So I have to find a way to take advantage of the GPU Decoder/Encoder. (i.e. Comskip runs at about 200-400fps on my Intel Core2Duo and about 12fps on the RPi)
  • Choosing what language to write this in. Bash may be sufficient to do the job but I know PHP much better than Bash which would give me a heads up on dev. time but would require having a server. A compiled language is always nice but a bit overkill for something that will really only be calling other executables and keeping a small database.
  • Time (believe it or not I don’t have much free time, lol)

Resources I’m looking at to solve this:

http://stackoverflow.com/questions/22432566/mpeg2-to-h264-wtih-gstreamer

http://www.raspberrypi.org/forums/viewtopic.php?f=38&t=6852&start=75

http://theiopage.blogspot.com/2013/04/enabling-hardware-h264-encoding-with.html (pre-built RPi Gstreamer library with Open Max support)

https://solarianprogrammer.com/2015/01/13/raspberry-pi-raspbian-install-gcc-compile-cpp-14-programs/ (for compiling comskip which I completed)

5 thoughts on ““Commercial Clapper” script

  1. So this blogpost via a Google search. I’m looking for a way to do comskip with PlexDVR as the recorder, running on a Xpenology (Synology code on homebuilt NAS) server. The latest PlexDVR beta has a way to postprocess when a recording finishes (not easy to enable, but there). I’d like to see if your approach can be made to work in that environment. Would you mind an occasional email requesting help when I try to translate the TVHeadend parts over to PlexDVR?

    1. I cant guarantee I can always respond quickly or have an answer but feel free to bounce questions off of me and I will help where I can.

  2. Jeff, Not to take you away from what Andrew is doing, but I found this script and found it useful for using Plex to remove commercials. Just need to get the Trancoding bit from .ts to mkv.

Leave a Reply