PostProccessing: Usage Examples

FYI, for anyone who is interested, I just posted my own bare-bones post-processing script for Ubuntu 14.04 server.

github.com/nebhead/PlexPostProc

I got frustrated with FFMpeg and Comskip so I just said forget it and used Handbrake CLI instead. No commercial skipping, just transcoding to 720p. No muss, no fuss.

Hope this helps someone else out there who needs a simple guide to get this up and running.

How long should the post-processing take for say a 30 minute show and how can I confirm it’s running? Are there any logs I should be looking at to troubleshoot because I don’t see much of anything except for Python running after the video has completed recording.

The PMS logs will show that it tried to use it, search for the name of the script in the logs.
If you want to see what the python script is doing you could add the following

#!/bin/sh
/usr/bin/mkvpropedit "$1" --edit track:a1 --set language=eng --edit track:v1 --set language=eng
sleep 5
/usr/bin/python /path/to/PlexComskip.py "$1" > /path/to/where/you/want/log/stored/output.log

and then to watch what is going on use

$ tail -f /path/to/where/you/want/log/stored/output.log

@hthighway said:
The PMS logs will show that it tried to use it, search for the name of the script in the logs.
If you want to see what the python script is doing you could add the following

#!/bin/sh
/usr/bin/mkvpropedit "$1" --edit track:a1 --set language=eng --edit track:v1 --set language=eng
sleep 5
/usr/bin/python /path/to/PlexComskip.py "$1" > /path/to/where/you/want/log/stored/output.log

and then to watch what is going on use

$ tail -f /path/to/where/you/want/log/stored/output.log

Ok my issue is def. related to PlexComskip.conf. The default locations are definitely not right for my setup. I checked my /usr/local/bin directory and it’s completely empty. No ffmpeg or comskip. I found my comskip directory in /home/myuseraccount/Comskip which is also where my /PlexComskip directory is. Still not sure where my ffmpeg is located.

My Linux noobness is really showing through today…

@IamSpartacus said:

@hthighway said:
The PMS logs will show that it tried to use it, search for the name of the script in the logs.
If you want to see what the python script is doing you could add the following

#!/bin/sh
/usr/bin/mkvpropedit "$1" --edit track:a1 --set language=eng --edit track:v1 --set language=eng
sleep 5
/usr/bin/python /path/to/PlexComskip.py "$1" > /path/to/where/you/want/log/stored/output.log

and then to watch what is going on use

$ tail -f /path/to/where/you/want/log/stored/output.log

Ok my issue is def. related to PlexComskip.conf. The default locations are definitely not right for my setup. I checked my /usr/local/bin directory and it’s completely empty. No ffmpeg or comskip. I found my comskip directory in /home/myuseraccount/Comskip which is also where my /PlexComskip directory is. Still not sure where my ffmpeg is located.

My Linux noobness is really showing through today…

Type:

$ whereis ffmpeg

Is there a quide/faq for postprocessing?

I’m recording to .TS transport stream because my server isn’t very beefy. Skimming through the previous pages makes me think that any transcoding I do needs to keep the video in .TS otherwise it won’t be spotted by the Plex server after postprocessing completes.

Is that correct or is there some sort of callback to let the server know the file format/container has changed?

@colinirwin setting Plex to remux from your HDHomerun doesn’t take much if anything from a CPU perspective. Everything will then already be .mkv if you chose to transcode the video via post processing.

@jondhoughton said:
@colinirwin setting Plex to remux from your HDHomerun doesn’t take much if anything from a CPU perspective. Everything will then already be .mkv if you chose to transcode the video via post processing.

I’d originally tried remux and the recording failed. Tried again just now - same thing. Then I looked at the record dates on my server and realised the DVR hadn’t been recording since Oct 1st so I deleted the HDHomerun and added it back and the remux now works.

Many thanks!

So next question - is there a Windows (server 2012 r2) guide for transcoding?

I have the following installed on the server:

  • Handbrake
  • MCEBuddy 2.4 (full version)
  • Comskip

I used to have scripts running for NextPVR but I have disabled it since the Radio Times XML feed ended.

@colinirwin said:
So next question - is there a Windows (server 2012 r2) guide for transcoding?

I have the following installed on the server:

  • Handbrake
  • MCEBuddy 2.4 (full version)
  • Comskip

I used to have scripts running for NextPVR but I have disabled it since the Radio Times XML feed ended.

The Windows guide is in this thread:
https://forums.plex.tv/discussion/232730/guide-commercial-free-experience-with-plex-dvr/p1

@jasonmicron said:
veryslow is … very slow. I don’t use any preset when I encode a rip. This is how I run it, and it does a generally ok job. Nothing fancy, all it does is encode to H.264 and just copies the audio channel and any subtitles baked into the MKV container:

ffmpeg -i <input file> -acodec copy -vcodec libx264 -scodec copy <output file>

I have tinkered with some other settings like crf and the presets. I read somewhere that if you start mucking with crf that you should also use the qcomp flag to maintain some extra fidelity:

-vcodec libx265 -preset slower -crf 20.0 -qcomp 0.8

Running the same ffmpeg, using the -scodec copy, I don’t get the subtitles. Do you? How do you handle deinterlace? What if a file isn’t interlaced? How do you detect it?

I’m running into issues compiling comskip after compiling the latest FFMPEG from source. Specifically, comskip is complaining about libavutil, libavformat, and libavcodec. I have the latest versions of these packages installed for my distro (Ubuntu Server, 16.04.1 LTS).

— ~/Comskip ‹master› » ./configure
checking for a BSD-compatible install… /usr/bin/install -c
[…snip…]
checking for argtable2… yes
checking for ffmpeg… no
configure: error: Package requirements (libavutil >= 54.7 libavformat >= 56.4 libavcodec >= 56.1) were not met:

Requested ‘libavutil >= 54.7’ but version of libavutil is 54.3.0
Requested ‘libavformat >= 56.4’ but version of libavformat is 56.1.0

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables ffmpeg_CFLAGS
and ffmpeg_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

@ascagnel This helped me when compiling on Mac: https://forums.plex.tv/discussion/comment/1257286/#Comment_1257286

Apparently it’s not finding it in the expected location.

I’ve written a windows program for myself personally. I wrote it before the post processing option was around, but it still works fine. It just monitors the recordings folder for .ts files, runs comskip, splits the file and rejoins it, then remuxes it to MP4 whilst converting the audio to AAC.

It works really well, but I haven’t added anything customisable to it yet like downsampling or anything.

If anyone is interested, I could release it at some point, but it’s not really something I intend to work on outside of my own personal usage.

@mkmorris said:
Alright, I’ve read through the python script and am looking to use MCEBuddy (paid) with ComSkip (paid). What I can’t figure out is where the “file” variable is passed, or what environment variable it is on Windows so I can pass it to MCEBuddy.UserCLI and add it to the processing queue.

So, is it %1, or etc?

Or am I missing some documentation somewhere.

Well let me tell you how I do it. I have plex record and rather than mucking around with postprocessing under advanced options in mcebuddy you can have it watch for “changed” items. I set mine to process when that file is 2 hours old.

Mcebuddy does the rest for me and I don’t need to anything other than empty my archive folder once in a while.

OK, I figured out my previous issue (I had to update my PKG_CONFIG_PATH to my local ffmpeg build folder, in my case it was ~/ffmpeg_build/, and I was using the guide posted on FFMPEG’s website, in case someone else comes across this); however, running the build on a headless Ubuntu Server 16.04 system, I’m running into compile errors related to XCloseDisplay, XOpenDisplay, vaGetDisplay, XDisplayName, vaGetDisplayDRM. As best as I can tell, I have the X11/Xorg and SDL dev libraries installed.

Make log:

--- ~/Comskip ‹master* ?› » make
gcc -g -O2 -mtune=generic    -o comskip comskip-comskip.o comskip-mpeg2dec.o comskip-platform.o comskip-video_out_dx.o ccextratorwin/comskip-608.o ccextratorwin/comskip-ccextractor.o ccextratorwin/comskip-encoding.o ccextratorwin/comskip-general_loop.o ccextratorwin/comskip-myth.o -largtable2 -L/home/ascagnel/ffmpeg_build/lib -lavformat -lXv -lX11 -lXext -ldl -lvdpau -lva -lva-drm -lva -lva-x11 -lva -lxcb -lXau -lXdmcp -lxcb-shm -lxcb -lXau -lXdmcp -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lXau -lXdmcp -lxcb-shape -lxcb -lXau -lXdmcp -lX11 -lasound -lx265 -lstdc++ -lm -lrt -ldl -lx264 -lpthread -lm -ldl -lvpx -lm -lpthread -lvpx -lm -lpthread -lvpx -lm -lpthread -lvpx -lm -lpthread -lvorbisenc -lvorbis -logg -ltheoraenc -ltheoradec -logg -lopus -lm -lmp3lame -lfreetype -lz -lpng12 -lz -lm -lfdk-aac -lm -lass -lm -lharfbuzz -lfontconfig -lexpat -lfreetype -lexpat -lfribidi -lfreetype -lz -lpng12 -lz -lm -lbz2 -lz -pthread -lavcodec -lXv -lX11 -lXext -ldl -lvdpau -lva -lva-drm -lva -lva-x11 -lva -lxcb -lXau -lXdmcp -lxcb-shm -lxcb -lXau -lXdmcp -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lXau -lXdmcp -lxcb-shape -lxcb -lXau -lXdmcp -lX11 -lasound -lx265 -lstdc++ -lm -lrt -ldl -lx264 -lpthread -lm -ldl -lvpx -lm -lpthread -lvpx -lm -lpthread -lvpx -lm -lpthread -lvpx -lm -lpthread -lvorbisenc -lvorbis -logg -ltheoraenc -ltheoradec -logg -lopus -lm -lmp3lame -lfreetype -lz -lpng12 -lz -lm -lfdk-aac -lm -lass -lm -lharfbuzz -lfontconfig -lexpat -lfreetype -lexpat -lfribidi -lfreetype -lz -lpng12 -lz -lm -lbz2 -lz -pthread -lswresample -lm -lavutil -lm  -lpthread -lm 
/home/ascagnel/ffmpeg_build/lib/libavutil.a(hwcontext_vaapi.o): In function `vaapi_device_free':
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:829: undefined reference to `XCloseDisplay'
/home/ascagnel/ffmpeg_build/lib/libavutil.a(hwcontext_vaapi.o): In function `vaapi_device_create':
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:859: undefined reference to `XOpenDisplay'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:864: undefined reference to `vaGetDisplay'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:871: undefined reference to `XDisplayName'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:861: undefined reference to `XDisplayName'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:885: undefined reference to `vaGetDisplayDRM'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:859: undefined reference to `XOpenDisplay'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:861: undefined reference to `XDisplayName'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:866: undefined reference to `XDisplayName'
/home/ascagnel/ffmpeg_build/lib/libavutil.a(hwcontext_vdpau.o): In function `vdpau_device_create':
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:432: undefined reference to `XOpenDisplay'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:438: undefined reference to `XDisplayString'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:440: undefined reference to `XDefaultScreen'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:440: undefined reference to `vdp_device_create_x11'
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:434: undefined reference to `XDisplayName'
/home/ascagnel/ffmpeg_build/lib/libavutil.a(hwcontext_vdpau.o): In function `vdpau_device_free':
/home/ascagnel/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:411: undefined reference to `XCloseDisplay'
collect2: error: ld returned 1 exit status
Makefile:457: recipe for target 'comskip' failed
make: *** [comskip] Error 1

@pallotto said:

@mkmorris said:
Alright, I’ve read through the python script and am looking to use MCEBuddy (paid) with ComSkip (paid). What I can’t figure out is where the “file” variable is passed, or what environment variable it is on Windows so I can pass it to MCEBuddy.UserCLI and add it to the processing queue.

So, is it %1, or etc?

Or am I missing some documentation somewhere.

Well let me tell you how I do it. I have plex record and rather than mucking around with postprocessing under advanced options in mcebuddy you can have it watch for “changed” items. I set mine to process when that file is 2 hours old.

Mcebuddy does the rest for me and I don’t need to anything other than empty my archive folder once in a while.

I figured it out, anyhow, the %* worked better, it passes all args on a windows box.

For now however, I have moved back to my NextPVR config + MCEBuddy automatically doing my work for me and importing into Sonarr using NZBtoMedia, for naming, which notifies Plex.

Between the GraceNote data just being way too different than TVDB, season folders being named all different, Sonarr not being able to see Plex’s naming scheme, and the DVR being way behind the Plex Pass version, I’ve gone back to the old tried and true method.

@mkmorris said:

Between the GraceNote data just being way too different than TVDB, season folders being named all different, Sonarr not being able to see Plex’s naming scheme, and the DVR being way behind the Plex Pass version, I’ve gone back to the old tried and true method.

FWIW, I have not had problems with Sonarr reading Plex’s naming scheme. I did have to customize Episode Naming, so maybe that’s why it works. Here are my settings:

@Bollar said:

@mkmorris said:

Between the GraceNote data just being way too different than TVDB, season folders being named all different, Sonarr not being able to see Plex’s naming scheme, and the DVR being way behind the Plex Pass version, I’ve gone back to the old tried and true method.

FWIW, I have not had problems with Sonarr reading Plex’s naming scheme. I did have to customize Episode Naming, so maybe that’s why it works. Here are my settings:

Oh yeah, I toyed around with this… but I’m not about to rename my entire 8TB library to get something working that seems to name things in a way that nothing else names them like. In other words if Plex DVR could use “Scene” Naming, we might be onto something.

@mkmorris said:

Oh yeah, I toyed around with this… but I’m not about to rename my entire 8TB library to get something working that seems to name things in a way that nothing else names them like. In other words if Plex DVR could use “Scene” Naming, we might be onto something.

Okay… I didn’t have to change my naming scheme in Plex, just change Sonarr to the Plex format. Look at it again if you’re bored - maybe after Beta 5. :wink: