This a linux computer running plex 3.69.1
I put a postprocessing script in the dvr settings, but I can’t it to run or do anything. This is what the logs look like:
Sep 15, 2018 22:31:30.263 [0x7feed53ff700] DEBUG - Job running: '/full/path/to/script.sh' '/full/path/to/plex/tv/.grab/a29ec49011b6c5c2997b8f8eb1cc080f7662aa12/show name.ts'
Sep 15, 2018 22:31:30.266 [0x7feed53ff700] DEBUG - Jobs: Starting child process with pid 15414
Sep 15, 2018 22:31:30.292 [0x7feed23ff700] DEBUG - Jobs: '/full/path/to/script.sh' exit code for process 15414 is 0 (success)
Sep 15, 2018 22:31:30.292 [0x7feed53ff700] DEBUG - DVR:Recorder: Postprocessing script '/full/path/to/my/script.sh' was successful in 0.0 seconds. Nicely done.
Now obviously, it cannot have actually done anything in 0.0 seconds.
My first version of the script was written to output to a temp file then replace the input file, like this:
#!/bin/bash
FILENAME=$1
TEMPFILENAME="$(mktemp)" # Temporary File for transcoding
ffmpeg -i "$FILENAME" -f lavfi -i "movie=$FILENAME[out0+subcc]" -map 0 -map 1:s -c:a copy -c:s srt -c:v libx265 -crf 23 -preset faster -f matroska "$TEMPFILENAME"
rm -f "$FILENAME" && mv -f "$TEMPFILENAME" "${FILENAME%.ts}.mkv"
Since that exits immediately according to the log, I tried outputting to stdout, because I figured that plex might be executing this as part of a pipeline:
#!/bin/bash
FILENAME=$1
ffmpeg -i "$FILENAME" -f lavfi -i "movie=$FILENAME[out0+subcc]" -map 0 -map 1:s -c:a copy -c:s srt -c:v libx265 -crf 23 -preset faster -f matroska pipe:1
That had the same result though. The scripts “finish” immediately. I ran the first version manually against one of the TV shows again. And that took a while because it was actually doing its job.
The only difference I can see between when the script ran from plex vs me running it manually, is that plex provides what looks like a temporary file as its argument, whereas I specified the location of the recorded show after plex moved it. And I don’t know if that’s a lead or not.
Any help is appreciated if anyone knows how to get this working and actually encoding.