DVR Postprocessing script for Handbrake on Windows --- help? Examples?

Why is the first set of quotes weirdly “low” in the input filename? Any possibility that is your issue? Almost looks like two commas?

https://i.imgur.com/Jx8OvBL.png

If you’re reunning Windows why not download mcebuddy, point it to your recording library and let it monitor for new recordings and process them when found. You can set a default conversion and whether you want commercial removal run. This way you don’t even need to worry about post processing and trying to figure out the bat file processing. It can even archive the original at file. I used to run mcebuddy with a post processing script and have even stopped doing that, justnlet it Monitor a couple of folders I record different shows to and let it do its thing.

1 Like

The reason why the first quotes are low is because i copy and paste it from word haha :smiley:
I checked it again and still the same error.

@johnm_colaSC thanks for this hint. does this software only pick the new recorded files? My libary is very big and if the software converts everything it finds ill have a problem.

It will pick based on whatever you specify as far as files. I have mine set to look for *.ts in the folders it monitors. So any ts file would be processed. MCEBuddy also has some fine tuning you can do for instance I have all shows except my nightly news recordings have commercials removed and are converted from the h264 my HDHR Extends transcode the video to before sending to Plex to h265 for permanent storage, the nightly news programs only get commercials stripped.

Am I correct that if you want the free MCEbuddy, you a relegated to a pretty old version, and need to pay to have access to the latest?

My goal is to limit needing to install and learn other apps in this process, so since Handbrake and this very small script work and is understandable to me I will continue this way.

1 Like

@Cortopassi you are correct on MCEBuddy, but the paid version is like $35 and well worth it. I have it running on my Windows 10 server watching multiple folders on my Qnap NAS and it grabs the .ts file, removes the commercials and puts it back into another subfolder. It’s quite robust on controls and automation.

I was going to comment with the same thing earlier but didn’t since he stated he was going to continue the Handbrake route. I totally agree with you between the small fee for the current version of MCEBuddy and the $10 I believe I paid for the full Comskip app I think it was money well spent and wouldn’t give it a second thought if I needed to do it again.

Thanks all. However, just to give my side of the story, I just RMA’ed my main computer’s video card, had to scramble to find a backup card, another piece of software stopped working and I updated three family phones.

I am sick of technology currently. I almost thought it might be worth the monthly fee for YouTube TV which has cloud DVR and just dump all this local recording and Plex membership fee for DVRing.

I am trying to simplify my technology life, not increase things I need to manage! :grinning:

Thanks for the answers on this thread - PLEX seems to have removed the option to remux DVR recordings to mkv - but after combing over this thread I have a batch file now that just remux the .ts into .mkv in the post processing step. Then MCEBuddy takes over.

c:\ffmpeg\bin\ffmpeg.exe -i %1 -c copy -map 0 "%~dpn1.mkv"
del %1

@bialio if you are using mcebuddy why do you care about running a ffmpeg command to remux to mkv? Set your mcebuddy profile to mkv unprocessed and mcebuddy will remux the container from ts to mkv.

Plex gets twitchy if you rename one of the DVR’d .ts files - says it’s UNAVAILABLE in a little red box.

You can go in and manually delete the “missing” file, but that’s way too much hassle :wink:

I do this with every recording but to mp4 instead of mkv and never see the red unavailable that you are describing. Might want to check the library settings you have selected in Plex, perhaps it is not scanning when changes are detected.

I don’t see any settings that are out of whack - it’s set to scan on any change as well as hourly.

Do you delete the old file when MCEBuddy is done? Or keep both versions?

Delete the old file.

Actually I just thought about it and I actually have mcebuddy archive the original. I then keep those around until I notice the drive the archive folder is located on getting down below 500GB remaining and then I go clean out a bunch of old recordings.

But irregardless of delete or archive there is only one copy of the episode, the mp4 version, in the Plex Library after mcebuddy is done. I never see any messages about deleted or missing items when I look at my primary Plex server. I do see those messages all the time on my Shield Plex Server since I do not have the empty trash setting enabled as most of my storage for that server is on network storage and I don’t want Plex removing the items if the network storage is not available for some reason when a library scan is done.

I’ve found MCEBuddy to be a great partner to Plex for post processing. Depending on if you have either QuickSync or an NVidia card, hardware acceleration makes a huge difference in encode time - I convert everything to H265 (HEVC).

The Script I use is:

@echo off
C:\Progra~1\MCEBuddy2x\MCEBuddy.UserCLI.exe --command=engine --action=start 
timeout /t 2 /nobreak > NUL
C:\Progra~1\MCEBuddy2x\MCEBuddy.UserCLI.exe --command=addfile --action=%1
timeout /t 10 /nobreak > NUL
:loop
for /f "delims=" %%o in ('C:\Progra~1\MCEBuddy2x\MCEBuddy.UserCLI.exe --command=jobstatus --action=%1 --quiet') do set status=%%o
if %status% == "not present" (
	Exit
) else (
	timeout /t 2 /nobreak > NUL
	goto loop
)

I’ve also developed my own H265 profile that I use for the encoding task:

[MKV HVEC Profile Constant Quality]
Description=WARNING: Handbrake Constant Quality encoding (23) with Nvidia HVEC.
order=ffmpeg, handbrake
AllowH264CopyRemuxing=true
FixedResolution=true
AutoDeinterlace=true
ffmpeg-UsingHardwareEncoding=True
ffmpeg-general=-threads 0 -hwaccel auto
ffmpeg-video=-ss 9 -c:v hevc_nvenc -cq 23 -rc vbr -map 0:v
ffmpeg-audio=-acodec ac3 -ab 192k -map 0:a
ffmpeg-audioac3=-acodec ac3 -ab 384k -map 0:a
ffmpeg-ext=.mkv
ffmpeg-audiodelay=skip
handbrake-UsingHardwareEncoding=true
handbrake-general=--decomb --denoise="weak" --loose-anamorphic --verbose=2 -T -O
handbrake-video=--start-at duration:3 -e x265 -q 18 
handbrake-audio=-E ffac3 -R auto -B 192 -D 0 -a 1,2,3,4,5
handbrake-audioac3=-E ffac3 -R auto -B 384 -D 0 -a 1,2,3,4,5
handbrake-ext=.mkv
handbrake-audiodelay=skip
PreConversionCommercialRemover=true

Be sure to check that the FFMpeg version is 3.0 or greater - that has the NVidia encoding included. You can replace the ffmpeg.exe with the latest version from ffmpeg.org (looks like the latest is up to v4.1).

In my experience, there’s no advantage to holding onto the original .TS file - the commercials have already been taken out (if you’re doing that), and the file is just huge. MCEBuddy has an option to automatically delete the original, following a successful conversion.

Hope it helps.

I wish Plex would allow user to specify saving as a mp4 instead of .ts. What a pain in the butt we all have to go thru to deal with this.

2 Likes

I also found a working script now:
Put this script as an batch file in the .grab recording directory.
Then write the script path name into the box in Plex DVR.

C:\Handbrake\HandBrakeCLI.exe --preset-import-file “PresetFileName” --preset “PresetName” -i %1 -o “%~dpn1.mp4”
del %1

The only thing not working is, that plex is not able to remove german commercials at the moment.
Ill wait for the next update.

Hello MovieCloud!

Thanks for your script, I created a BAT file called convert.bat with the code below. However, I am not seeing any output when the script runs. No new files are created. Have I done something wrong? I ran the the “.Json” portion successfully with manually defined -i and -o in command prompt. I commented out the “del %1” as Plex gave an error saying the script deleted the file.

“C:\Program Files\HandBrake\HandBrakeCLI.exe” --preset-import-file “C:\Users\cyber\Videos\TV\MyPreset.json” --preset “MyPreset” -i %1 -o “%~dpn1.mp4”
rem del %1

Thanks in advance!

Agreed. On the flipside we get to learn a bit about video processing and the knowledge required to deal with it as such. So, win? :thinking:

In our case we are cutting the cord from DysfunctionalTV (DirecTV), so the learning curve is worth it if it means ditching said dysfunction.

This script seems to work well for us:

@ECHO OFF
D:\Broadcasts\HandBrakeCLI.exe --preset "Fast 1080p30" --native-language eng --native-dub --subtitle scan,1,2,3 --subtitle-default=1 --main-feature -i %1 -o "%~dpn1.m4v" && (
del %1
)

Note the use of error handling to only delete the input file if the conversion completes without error. Also note the inclusion of subtitles, which do not occur by default and are required if desired in the conversion.