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.
If I wanted to postprocess and end up with three versions:
One as originally recorded, one with commercials cut, and the third version with commercials marked as chapters only. I would end up with three files… I could rename them easily enough in the script, but these will be created in the .grab directory where the source recording is, so how to move them into the right place? I assume the original one will be moved by Plex, as the filename will not have changed, but the new ones I created… ? Unless I made a separate library or hardcoded the path, but then you loose the automatic Show/Season/Episode structure.
I wanted to share my science project that started in large with eki1337’s PlexComskip script.
I wanted to ensure that I wouldn’t have collisions and multiple post processing scripts running and burning the CPU on my Ubuntu VM considering I could be recording 3 shows at the same time.
The below image is a rough flow chart of where I am today:
It has a small plex_post.py file that accepts the plex dvr file name, moves it out of the .grab folder into a working folder and then adds it to a queue, then (if it is not already running) launches the worker process (ppc_deamon.py) which actually does the heavy lifting by doing the actual comskip/ffmpeg work.
I have added pushbullet communications to let me know when a file is added to the queue, and when it finishes as well.
It is a work in progress, and I am by no means a good python programmer, this is certainly a learning experience for me.
I did build this in Ubuntu using python 2.7, so I have no clue if it will work on win32/MacOS, it wasn’t my use case.
My README.md has current status and a bit more information as to what it does.
I hope it gives some people either ideas, or added functionality to their current post processing in plex.
You can get it at the following:
I would suggest that you try and run it interactivly at the start until you validate it functions, and please run it as the same user as you would have plex run as. In my case the following:
sudo -u plex /opt/plex_post/plex_post.py
This ensures that your plex user actually has all permissions, and appropriate file support.
@Izzin said:
I wanted to share my science project that started in large with eki1337’s PlexComskip script.
Wow, this is interesting. I haven’t tried to test it out yet, but just looking at the flowchart I am wondering that if you exit the plex_post.py script as called by Plex before the final version has been converted, how does the move/add to library work? I thought that the post-processing was all done in the .grab directory and that Plex moved things into the library only when you exited. But if you exit before the procesing is done, what happens?
Wow, this is interesting. I haven’t tried to test it out yet, but just looking at the flowchart I am wondering that if you exit the plex_post.py script as called by Plex before the final version has been converted, how does the move/add to library work? I thought that the post-processing was all done in the .grab directory and that Plex moved things into the library only when you exited. But if you exit before the procesing is done, what happens?
Yeah, what you are describing was my first challenge, because the plex_post is so light weight and is really a queue manager first and foremost once it entered the file in to the queue Plex took over and deleted the file out of the .grab folder.
So after I qualify that the file is valid, I move the file into the intersitial folder defined in the ppc.conf file. Within that folder I create a working directory … so in short, .grab/uuid/Video.ts file → intersitial/working/Video.ts. From here, I enter the working/Video.ts file into the queue and the ppc_daemon does it work.
I have a bit of code as well, it will only move the file if the starter file actually exists in .grab, if you use this to process a file not in grab it will process it from the current location. I just needed to handle the .grab folder to prevent plex from moving the file to someplace I wasnt expecting it.
As for the add/move to library functions, I use Sonaar to manage my episode catalog, so the filebot renamer is there to rename from Plex format to Sonaar favored, the renaming process does a move in the function as well into the sonaar drone folder. Then Sonaar records and places the video into the correct location.
Right now this only works with TV episodes, I havent extended it or have a function to manage movies, however I do have a check that validates if it is an episode, so it would not be very difficult to have a differnt outcome for a movie. (IE move directly into your library)
@ascagnel said:
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.
Reorder your library includes in the Makefile. Find these “-lX11 -lm -lvdpau -lva -lva-drm -lva-x11” take them out of wherever they are in the “ffmpeg_LIBS” line, and then throw them on the end of the line like this:
I’m getting a seemingly obvious issue, Permission Denied, but I can’t seem to find what permissions it’s talking about. I just set up all the prereqs per this post on Linux Mint 18.2, and I’m trying to test with a small file. I’ve tested with the file on its normal drive, and local to the server but still get the Permissions error. What am I missing? Thanks!
sudo ./plexpostprocessing.sh /mnt/hgfs/Television/Friends\ \(1994\)/Season\ 03/Friends\ \(1994\)\ -\ S03E08\ -\ The\ One\ With\ the\ Giant\ Poking\ Device.ts
Error: The file '/mnt/hgfs/Television/Friends (1994)/Season 03/Friends (1994) - S03E08 - The One With the Giant Poking Device.ts' is not a Matroska file or it could not be found.
PlexComskip got invoked from /home/ryan/PlexComskip/PlexComskip.py
fatal: Not a git repository (or any of the parent directories): .git
Using session ID: a8e53a2f-9d10-4e73-9740-e23e9a08447d
Using temp dir: /home/ryan/a8e53a2f-9d10-4e73-9740-e23e9a08447d
Using input file: /mnt/hgfs/Television/Friends (1994)/Season 03/Friends (1994) - S03E08 - The One With the Giant Poking Device.ts
[comskip] Command: ['/home/ryan/Comskip/', '--output', '/home/ryan/a8e53a2f-9d10-4e73-9740-e23e9a08447d', '--ini', '/home/ryan/PlexComskip/comskip.ini', '/mnt/hgfs/Television/Friends (1994)/Season 03/Friends (1994) - S03E08 - The One With the Giant Poking Device.ts']
Something went wrong during comskip analysis: [Errno 13] Permission denied
Leaving temp files in: /home/ryan/a8e53a2f-9d10-4e73-9740-e23e9a08447d
Done processing!
@phiredrop said:
I’m getting a seemingly obvious issue, Permission Denied, but I can’t seem to find what permissions it’s talking about. I just set up all the prereqs per this post on Linux Mint 18.2, and I’m trying to test with a small file. I’ve tested with the file on its normal drive, and local to the server but still get the Permissions error. What am I missing? Thanks!
Made some progress switching over to the comcut script which seems to function well. Time to merge the compression script and comcut script!
@phiredrop said:
I’m getting a seemingly obvious issue, Permission Denied, but I can’t seem to find what permissions it’s talking about. I just set up all the prereqs per this post on Linux Mint 18.2, and I’m trying to test with a small file. I’ve tested with the file on its normal drive, and local to the server but still get the Permissions error. What am I missing? Thanks!
Made some progress switching over to the comcut script which seems to function well. Time to merge the compression script and comcut script!
I’m in the exact same boat. I haven’t played around with comcut yet. Were you able to make any progress with this script?
Something went wrong during comskip analysis: [Errno 13] Permission denied
@SumOfOneInteger Comcut is working pretty well. It’s running on the original .ts file. I’m still playing with transcoding options to see what works best for my setup, but that’s a manual process right now as I test it and try to trim the file sizes.
Can I request some suggestions? All I want to do (on Windows) is remux from TS to MKV container. My tuner is already outputting h264, and I’m happy with Plex’s built-in commercial removal. Seems like this should be a single line ffmpeg command, but lacking postprocessing documentation (I can’t find it) I’m not sure how to set it up so it returns what Plex needs.
FYI my purpose here is to try to improve some FF/RW performance issues I’m having (completely broken on Fire TV stick; flaky on Chromecast).
@bobomo. Plex sends your post processing script the file that was just recorded, something like:
G:\TV_DVR.grab\95b490902c7fafd95079c14a69bc13ab90ffd8a0\2018 Winter Olympics (2018) - 2018-02-11 15 00 00 - Speed Skating Biathlon Cross-Country Skiing.ts. Your script can then do whatever it wants with the file and place a modified version in the same folder with a new name: G:\TV_DVR.grab\95b490902c7fafd95079c14a69bc13ab90ffd8a0\2018 Winter Olympics (2018) - 2018-02-11 15 00 00 - Speed Skating Biathlon Cross-Country Skiing.mkv, and delete the original file. When your script finishes, Plex will move the file in the directory to it’s final location in your library.
@johnm_ColaSC said: @bobomo. Plex sends your post processing script the file that was just recorded, something like:
G:\TV_DVR.grab\95b490902c7fafd95079c14a69bc13ab90ffd8a0\2018 Winter Olympics (2018) - 2018-02-11 15 00 00 - Speed Skating Biathlon Cross-Country Skiing.ts. Your script can then do whatever it wants with the file and place a modified version in the same folder with a new name: G:\TV_DVR.grab\95b490902c7fafd95079c14a69bc13ab90ffd8a0\2018 Winter Olympics (2018) - 2018-02-11 15 00 00 - Speed Skating Biathlon Cross-Country Skiing.mkv, and delete the original file. When your script finishes, Plex will move the file in the directory to it’s final location in your library.