DVR Post Processing Script Issue converting TS file to MP4

Server Version#: Ubuntu 20.04
Player Version#: Plex Version 1.20.4.3517
Tuner Make/Model: Hauppauge Quad
Guide/Lineup name: N/A
Using XMLTV?: No
Channel number/Name: N/A

I used a combination of these two links as a tutorial to set up a plex dvr post processing script, which worked when installed on Ubuntu 18.04. Last week, feeling brave I decided to do a fully fresh install of Ubuntu 20.04. No problems and the Plex dvr does record shows successfully. However the intent of my script is to cut the commercials and also convert the .ts file to a 720p mp4.

This worked on the old system but does not work on the new system. I know the script executes because it generates the script processing log. I also performed the chmod 777 to the script per the recommendation in the web link. I’ve tinkered with the permissions on the Plex DVR media folder I created too, with no success. I also have the Plex dvr configured to detect and cut commercials so all that really needs to be done is convert the file to the mp4, which greatly reduces the file size.

At this point I’m not sure what the next step is. Thoughts? Thanks in advance.

https://www.danielcolomb.com/2017/03/29/setting-up-comchaps-comcut-with-comskip-ffmpeg-and-handbrakecli/

Seeing the same thing, I upgraded to 20.04 on my server last night. I can successfully run the script from the command line feeding it the file manually and it will transcode but it simply doesn’t transcode when using the post-processing function, script is running too as it is logging to the /tmp directory, but just seems to skip the actual ffmpeg step and errors out.

I even tried running it sudo -u plex and it runs successfully from the command line, but just not when called by the server it seems.

Yeah this one is a bit strange … did some more digging into the logs while it tries to transcode …

Decoder (codec mpeg2video) not found for input stream

… and yet, running the script from the command line functions as expected. Still digging :slight_smile:

Interesting - glad it’s not just me! Thanks for replying too. I’m still wondering if there is a permission/authority issue with either the script (probably not since it does run), but perhaps the target folder when writing the final output - but that doesn’t seem right either since plex dvr is able to write (a playable file) to that same location.

Yesterday I tried the code based on the script found here:


I tried this and it did not work at all so did try a hybrid approach, where I used this links instructions for installing ffmpeg and handbrake and then integrated it with my original script (after installing some additional packages) but now the dvr does capture a recording but the post processing fails and the file now won’t play at all since it shows a file size of zero bytes. So that leads me to believe the github code is totally broken (although it does say up front that it is a ‘beta’ package).

Now I’m writing a script to automate a fresh ubuntu/plex install since what I have now is basically useless.

Ahh - I love a good challenge. Just for fun I may reload Ubuntu 18.04 and see what happens.

Yeah it has to be a library permission thing or something as the error I eventually nailed down on mine was it wasn’t able to decode the mpeg2ts stream. So maybe some environment variables that aren’t set while Plex is running as a service.

I just worked around it instead, now recording with transcode while recording enabled since the server I’m using can manage it nicely, then let the commercial removal happen after it ends and I’m using Tdarr on the rest of my library anyway so it can do the transcode to HEVC. I’m only recording local news and Jeopardy for the most part with the odd other show thrown in here and there, so this is functional. Actually maybe better as now the show appears in Plex within a couple of minutes as h264 and Tdarr will covert that to HEVC within about 10. Prior to this I was doing it in software ffmpeg so it was about a 1:1 time ratio, so a 22 minute show would take a little over that to transcode.

Still, if anyone has a solution for why the post-processing script is broken I’d still like to mess around with it. Maybe I’ll dig a bit deeper myself and figure out why it’s having issues pulling in the external libraries.

This started today for me also I had upgraded to Server 1.20.5.3600 then 1.21.0.3608 and now my post processing script fails. Logs just says it exited error code 1 failed. But if I run the script as plex manually it works just fine. What does the server do differently in running the script?

If I downgrade to Server to 1.20.5.3583 post processing script works fine. (this is all on Ubuntu 18.04.5)

I did another full fresh install this past weekend using a fully automated script, and I can now again use the dvr (so if I screw anything up it only takes an hour to fully rebuild the system). I have another script that builds the post processing folders for comskip and comcut, and it also assigns what I hope are the the correct authority and ownership attributes to those folders and the postprocessing script. Tomorrow I plan to test it. Stay tuned.

Does anyone know what changed after 1.20.5.3583 in Linux package? If I upgrade past this version my post processing script will fail, how ever If I stay at this version it works just fine.

No one seems to be sure yet…

Its something to do with plex using its own libraries instead of ubuntu’s I finally got my script to debug more and its trying to use plex’s libraries for ffmpeg instead of the ones in ubuntu.

Interesting find. I wonder if modifying my script to use the plex ffmpeg would work? And if you don’t mind, care to briefly share how you debugged this? I also just noticed that I somehow inadvertently upgraded to the latest release. Hopefully I will get around to testing tomorrow as I got sidetracked today.

Well when I ran ffmpeg as plex it works fine uses the normal libraries but when the script runs i get this error from ffmpeg
[AVHWDeviceContext @ 0x559913229a00] libva: /usr/lib/plexmediaserver/lib/dri/iHD_drv_video.so has no function __vaDriverInit_1_0
[AVHWDeviceContext @ 0x559913229a00] libva: /usr/lib/plexmediaserver/lib/dri/i965_drv_video.so has no function __vaDriverInit_1_0
[AVHWDeviceContext @ 0x559913229a00] Failed to initialise VAAPI connection: -1 (unknown libva error).

So plex is some how force overriding the default libraries because only when ffmpeg is launched by plex its trying to use its library folders only

Hmm so I Google the error and got this on the first hit: https://askubuntu.com/questions/1093954/vainfo-returns-libva-error-usr-lib-x86-64-linux-gnu-dri-i965-drv-video-so-ini#1116081

Basically answer 2 says this:

A little late, but I ran into the same problem so I thought I’d leave what worked for me. Apparently you need the VDPAU (http://http.download.nvidia.com/XFree86/vdpau/doxygen/html/index.html) wrapper.

sudo apt-get install vdpau-va-driver

Fixed it…

Added this before my ffmpeg command
LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri/ /usr/bin/ffmpeg
After reading from that I found from a june 2020 post on reddit related to ubuntu 20.04 even though im on 18.04

Mind you I had already spent alot of time trying to mess with shared libraries
I Assume plex is setting the libva drivers path when its launching that script which was overriding the default because if you ran it as the plex username the libva drivers path is correct but it was changed only when plex launched the script.

Awesome! You rock! I will try a before and after test tomorrow.

No luck today. I spent several hours manually testing with both handbrake and ffmpeg. Will try again tomorrow.

For anyone interested, here’s a link to my working post-processing script:

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