Tvheadend Post Processing with Commercial Removal, Transcoding, & Plex/Kodi Naming Convention
Bash Script is located here:
(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:
- Comskip Linux port from here: http://forum.kodi.tv/showthread.php?tid=150084
- HandBrake CLI
- xmllint (libxml2)
- perl
- mencoder
- ffmpeg
- mc2xml setup with TVHeadend as instructed here (https://tvheadend.org/boards/4/topics/10322)
- Possibly more I’ve forgotten…
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:
- Build a queuing system and only post-process one at a time.
- Implement a SQL database for the Queue and to replace logging.
- 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)
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?
Not sure why first word is “So” instead of “Saw”… Fingers betray me.
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.
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.
Ooops forgot the link.
https://forums.plex.tv/discussion/232408/postproccessing-usage-examples/p1