[GUIDE] Scripts for Linux to re-encode recordings with Handbrake (optional) and mark commercials as MKV chapters

Code here: Bitbucket

Update: this was originally working for Windows and Linux, but the scripts have been completely re-tooled for a Linux environment. It will mark commercials as mkv chapters and output the raw MPEG2, H.264, or both files (with commercials marked).

original post below

I’ve tested the windows script, but not the linux one fully. I was originally trying to just have one bash script and use the Windows 10 bash to run it, but things got… complicated. :slight_smile:

Anyway, give those a shot and let me know what you think. It would be great to get a tester for the Linux one (to save me from setting up another test system). I haven’t had the heart to replace my production server with the beta yet.

Feel free to issue pull requests if you have ideas.

Ugh, forgot the key here: These go in the fancy new “post processing script” area of Beta 3

It’s a nice start. You’re using handbrake vs ffmpeg, which is fine. I dont recall if the profile handles deinterlacing, or what the output format is. Also, you may have speed concerns. You may want to just throw in the file extension as a variable and have it detect TS vs MKV

I’m currently working on a script that will transcode, strip commercials, file info look ups, etc. Just waiting for bugs to be worked out of Handbrake before I go mainstream with it

I’m not sure as well, but all the tests look like the source, so sure?. I use that profile for my rips, so I just copied stuff out of that script for this one. I have it require the MKV because handbrake can’t write to a TS file, and Plex requires the same filename in and out.

Just updated this stuff pretty substantially. It now marks the commercials as mkv chapters. BTW, Handbrake does auto decombing based on the source. I’ve also just updated it to work with whatever source (mkv or ts)

Awesome do your clients handle the chapters? I tried with Roku and fire TV and it didn’t seem to care about chapter markers just skipped 30 seconds or 10 mins still.

@ImCoKeMaN I’ve been seeing this as I’ve been using Plex more. The client on my LG tv will do chapter jumps (it’s up on the remote), but I can’t figure out how to do that with the windows 10 app, and the firestick app doesn’t do it :frowning:

@jnbarlow Trying this on linux debian. It appears that the library import moves the files from the .grab folder afterpost processing into it’s own folder structure organized by show/season etc. then once the cronjob runs it fails to locate the file to process… am I missing something? or has this not really been tested yet on linux?

@mattk926 I primarily use this on Ubuntu, so let’s try to figure out what’s going on here.

the first step is to edit the processTV.cfg file and change the dvrhome directory to match the directory of your dvr library (the processTV.sh script uses that as the base for a find command). You can do more things here as well (like turning off x264 output).

The second step is to set plexPost.sh as the post processing script. All this does is log the file name of the show that was just recorded (not the full path) to the ondeck file next to the script.

The third step is to set up a cron job to run processTV.sh. This uses the dvrhome directory defined above and looks for the filenames stored in the ondeck file. Once it finds one, it then processes it and moves on to the next one.

Note: if you don’t have comskip installed, the processTV.sh will fall on its face. If you ever need to reprocess something, all you need to do is add the filename back to the ondeck file and it’ll get picked up on the next run (you can also run it manually).

let me know if that helps, or if you’re still seeing something weird. There should be a log file in your /tmp directory as well.

I just realized that this was originally written as a guide for Windows and Linux… things have changed a lot since it was first made and it’s pretty much Linux only now :frowning:

Thanks for the update, yeah I had to make sure comskip and a few other dependencies were installed. seems to be working for now, but it does look like handbrake changed their default profiles since the script was put together, and now the profile that you have selected by default doesn’t exist.

@mattk926 Ahh yeah, you’re right. I use some other handbrake scripts and remember having to update it there.

Full disclosure, I just use the mpeg2 option myself. I found that if the recording ends up with artifacts, sometimes the h.264 conversion amplifies them (and I think the hardware I’m running plex on has a bad cpu).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.