GithubHelp home page GithubHelp logo

cedarrapidsboy / pms-postprocessing Goto Github PK

View Code? Open in Web Editor NEW
18.0 18.0 4.0 123 KB

Post processing scripts to augment the Plex Media Server DVR functionality.

License: MIT License

Shell 100.00%

pms-postprocessing's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pms-postprocessing's Issues

Commercial Skip (Hardware)

The current release version of Comskip that is distributed with Plex (public version), does not include hardware/GPU support. The true donator version of Comskip supports gpu analysis.

Here is what I did:

  1. Clone Comskip Linux repo - https://github.com/erikkaashoek/Comskip
  2. Compile the script and copy the file to the directory where Plex Commercial Skipper is located. named it Plex Commercial Skipper 2
  3. Modified the script to launch 'Plex Commercial Skipper2' and pass the following arguments: --hwassist --cuvid
  4. Add "hardware_decode=1", to the comskip.ini.

I need to move the comskip.ini and 'Plex Commercial Skipper 2' into a different directory, so it is not overwritten by Plex upgrades. I haven't had a chance to do that. When doing the commercial analysis in software, I was getting around 90fps. In Hardware (P2000), I get around 400-600fps, and cpu utilization isn't pegged at 100%.

Occasionally plex is reporting failures in post processing.

May 16, 2020 13:00:21.045 [0x7f00a2ffd700] WARN - SLOW QUERY: It took 13310.000000 ms to retrieve 0 items.
May 16, 2020 13:00:21.051 [0x7f00717fa700] DEBUG - buildLiveM3U8: min 0 max 19 ended 0
May 16, 2020 13:00:21.052 [0x7f00eaffd700] DEBUG - Request: [127.0.0.1:48410 (Loopback)] GET /livetv/sessions/764106e7-73c7-422a-986b-924709a3e87c/0b8ffcad-2ee6-488f-af91-41d24325a350/00018.ts (103 live) Signed-in
May 16, 2020 13:00:21.052 [0x7f00eaffd700] DEBUG - Content-Length of /media/PlexMedia1/transcode/Transcode/Sessions/plex-transcode-764106e7-73c7-422a-986b-924709a3e87c/media-00018.ts is 1754228 (of total: 1754228).
May 16, 2020 13:00:21.052 [0x7f00697fa700] DEBUG - Request: [127.0.0.1:48286 (Loopback)] GET /livetv/sessions/764106e7-73c7-422a-986b-924709a3e87c/0b8ffcad-2ee6-488f-af91-41d24325a350/00019.ts (103 live) Signed-in
May 16, 2020 13:00:21.052 [0x7f00697fa700] DEBUG - Content-Length of /media/PlexMedia1/transcode/Transcode/Sessions/plex-transcode-764106e7-73c7-422a-986b-924709a3e87c/media-00019.ts is 1766636 (of total: 1766636).
May 16, 2020 13:00:21.054 [0x7f00f29f5700] DEBUG - Completed: [127.0.0.1:48410] 200 GET /livetv/sessions/764106e7-73c7-422a-986b-924709a3e87c/0b8ffcad-2ee6-488f-af91-41d24325a350/00018.ts (103 live) 2ms 1754228 bytes (pipelined: 17)
May 16, 2020 13:00:21.054 [0x7f00f29f5700] DEBUG - Removed transcode data consumer, active count 2 => 1
May 16, 2020 13:00:21.055 [0x7f00f31f6700] DEBUG - Completed: [127.0.0.1:48286] 200 GET /livetv/sessions/764106e7-73c7-422a-986b-924709a3e87c/0b8ffcad-2ee6-488f-af91-41d24325a350/00019.ts (103 live) 3ms 1766636 bytes (pipelined: 3)
May 16, 2020 13:00:21.055 [0x7f00f31f6700] DEBUG - Removed transcode data consumer, active count 1 => 0
May 16, 2020 13:00:21.057 [0x7f0062fed700] ERROR - Recorder: Exception caught looking for post-processed file: boost::filesystem::directory_iterator::construct: No such file or directory: "/media/PlexMedia1/TVShows/.grab/baf1fe599e3f8add2fcf8741bf6a0c8f0e5df679-c51305b7fd58fd3c0df24350139664739866cda3"
May 16, 2020 13:00:21.057 [0x7f0062fed700] ERROR - Recorder: Postprocessing script '/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Scripts/transcode_internal.sh' seems to have deleted the file. Silly script.
May 16, 2020 13:00:21.057 [0x7f0062fed700] DEBUG - Grabber: Scheduling 'Guy's Grocery Games - E6 - Redemption Tournament: Part 4 (4/5)' for assimilation.
May 16, 2020 13:00:21.058 [0x7f0062fed700] DEBUG - Subscription: Resolved subscription to library item 'Guy's Grocery Games' (22361)
May 16, 2020 13:00:21.059 [0x7f0062fed700] DEBUG - There were 1 top-level paths for Guy's Grocery Games.
May 16, 2020 13:00:21.059 [0x7f0062fed700] DEBUG - Assimilator: Postprocessing, we're going to put `Guy's Grocery Games - E6 - Redemption Tournament: Part 4 (4/5)` in `/media/PlexMedia1/TVShows/Guy's Grocery Games/Season 09/Guy's Grocery Games - S09E06 - Redemption Tournament Part 4 (4 5).ts`
May 16, 2020 13:00:21.059 [0x7f0062fed700] ERROR - Assimilator: Error processing files: boost::filesystem::directory_iterator::construct: No such file or directory: "/media/PlexMedia1/TVShows/.grab/baf1fe599e3f8add2fcf8741bf6a0c8f0e5df679-c51305b7fd58fd3c0df24350139664739866cda3"
May 16, 2020 13:00:21.059 [0x7f0062fed700] DEBUG - Grabber: Operation for 'Guy's Grocery Games - E6 - Redemption Tournament: Part 4 (4/5)' on channel 6102 completed with status error (An error occurred while postprocessing the recording)
May 16, 2020 13:00:21.070 [0x7f0062fed700] DEBUG - Activity: Ended activity 024025dc-eda9-49bf-9754-23399ce045c4.```
---
Attached Files
[Plex Media Server.log](https://github.com/cedarrapidsboy/pms-postprocessing/files/4639314/Plex.Media.Server.log)
[plex -journalctl.txt](https://github.com/cedarrapidsboy/pms-postprocessing/files/4639315/plex.-journalctl.txt)

Any further development?

First off would like to say, I'm so happy to have come across this. Was pulling my hair out before I found it.

To my question, any way to change the container of the saved files? I just have more luck with mp4 or mkv playing through plex. TS containers are laggy.

PMS version 1.20.0.3113 "unable to determine video dimensions"

I am on PMS 1.20.0.3113 and just installed your script with high hopes. After copying the script to the scripts directory and specifying it in the DVR settings, i get the message below:

20200726-020119 [p3aEMX8D] INFO: transcode_internal.sh : Starting postprocessing for /DVR_Media/.grab/9dee844c194aa034cf1f0279c7eddaeaad92985d-3dc89e54a750dd6489d067d9ed0601d467db047a/Lost in Space (1965) - S02E15 - The Golden Man.ts.
20200726-020122 [p3aEMX8D] ERROR: transcode_internal.sh : Trasncode canceled. Unable to determine input video dimensions.
20200726-020122 [p3aEMX8D] INFO: transcode_internal.sh : Postprocessing completed. No work done. Removed /tmp/working.eUEiG4Nu.mkv.

I have confirmed the the script has the correct permissions and a umask of 0755. I am running this in an unRaid docker container with NVENC enabled.

MPEG2Video error to plex

When a video is already encoded a h.264, and "$ONLYMPEG2" is set, the script correctly does not process the file. However, it raises an error, which causes Plex to fail the recording.

In testing, I changed it to simply echo the error message, and then exit 0. When the recording already encoded it should not process, but also not raise an error to plex.

Is there any plan to add QSV encoding ?

Most Plex users use intel chips and with plex pass the hardware encoding feature uses Quick Sync to transcode. I was wonder if there was any chance of adding QSV support or at least test for it like you do with the nvidia encoder and use it if present.
Example transcode with QSV:

 /usr/lib/plexmediaserver/Plex Transcoder -codec:0 h264 -hwaccel:0 vaapi -hwaccel_fallback_threshold:0 10 -hwaccel_output_format:0 vaapi -codec:1 dca -analyzeduration 20000000 -probesize 20000000 -i /mnt/movies/life.like.2019.1080p.bluray.x264-getit.mkv -filter_complex [0:0]hwupload[0];[0]scale_vaapi=w=1278:h=538:format=nv12[1];[1]hwupload[2] -filter_complex [0:1] aresample=async=1:ocl='stereo':rematrix_maxval=0.000000dB:osr=48000[3] -map [2] -metadata:s:0 language=eng -codec:0 h264_vaapi -b:0 1898k -maxrate:0 2531k -bufsize:0 5062k -r:0 23.975999999999999 -force_key_frames:0 expr:gte(t,0+n_forced*5) -map [3] -metadata:s:1 language=eng -codec:1 aac -b:1 148k -f dash -seg_duration 5 -init_seg_name init-stream$RepresentationID$.m4s -media_seg_name chunk-stream$RepresentationID$-$Number%05d$.m4s -window_size 5 -delete_removed false -skip_to_segment 1 -time_delta 0.0625 -manifest_name http://127.0.0.1:32400/video/:/transcode/session/zuthbshnwnudgfcfl21encku/28430603-d1fd-4502-8c71-46b3caefeca5/manifest?X-Plex-Http-Pipeline=infinite -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 dash -start_at_zero -copyts -vsync cfr -y -init_hw_device vaapi=vaapi: -hwaccel_device vaapi -filter_hw_device vaapi -nostats -loglevel quiet -loglevel_plex error -progressurl http://127.0.0.1:32400/video/:/transcode/session/zuthbshnwnudgfcfl21encku/28430603-d1fd-4502-8c71-46b3caefeca5/progress
****

Hardware enabled Deinterlace

Looking at the Plex Transcoder, there appears to be support for the yadif_cuda filter, which should let this decode cuda as well. Any thoughts on how to get that in, or what issues it might cause?

Recording "fails" with rename error - recording is actually fine

Discovered a recording the PMS GUI labeled as a failure, but it played fine and was converted to H264 fine. No warnings or errors from the transcode script. However, the following log snippet shows a PMS error after transcoding:

May 13, 2020 23:00:08.772 [0x7fdaf3fff700] DEBUG - Jobs: '/config/Library/Application Support/Plex Media Server/Scripts/transcode_internal.sh' exit code for process 29620 is 0 (success)
May 13, 2020 23:00:08.932 [0x7fda717fa700] DEBUG - Recorder: Postprocessing script '/config/Library/Application Support/Plex Media Server/Scripts/transcode_internal.sh' seems to have renamed output file '"/share/CACHEDEV1_DATA/videos/Videos/TV Recordings/.grab/157ff26abfbaa01d4a11106325e9765b5e8cdff2-7f9f7b46b1f30e96a88eaba2808c869ec4e3f4a8/Survivor (2019) - S40E14 - It All Boils Down to This.ts"' to '"/share/CACHEDEV1_DATA/videos/Videos/TV Recordings/.grab/157ff26abfbaa01d4a11106325e9765b5e8cdff2-7f9f7b46b1f30e96a88eaba2808c869ec4e3f4a8/Survivor (2019) - S40E14 - It All Boils Down to This.mp4"'
May 13, 2020 23:00:08.932 [0x7fda717fa700] DEBUG - Recorder: Postprocessing script '/config/Library/Application Support/Plex Media Server/Scripts/transcode_internal.sh' was successful in 3608.1 seconds. Nicely done.
May 13, 2020 23:00:08.932 [0x7fda717fa700] DEBUG - Grabber: Scheduling 'Survivor - E14 - It All Boils Down to This' for assimilation.
May 13, 2020 23:00:08.938 [0x7fdaccff9700] DEBUG - HTTP requesting GET http://192.168.1.10:80/discover.json
May 13, 2020 23:00:08.941 [0x7fda25ffb700] WARN - SLOW QUERY: It took 1127490.000000 ms to retrieve 2 items.
May 13, 2020 23:00:08.945 [0x7fdaccff9700] DEBUG - HTTP 200 response from GET http://192.168.1.10:80/discover.json
May 13, 2020 23:00:08.946 [0x7fdaccff9700] DEBUG - HTTP requesting GET http://192.168.1.10:80/lineup_status.json
May 13, 2020 23:00:08.953 [0x7fda73fff700] DEBUG - Subscription: Resolved subscription to library item 'Survivor' (55104)
May 13, 2020 23:00:08.961 [0x7fdaccff9700] DEBUG - HTTP 200 response from GET http://192.168.1.10:80/lineup_status.json
May 13, 2020 23:00:08.982 [0x7fda73fff700] DEBUG - There were 1 top-level paths for Survivor.
May 13, 2020 23:00:08.982 [0x7fda73fff700] DEBUG - Assimilator: Postprocessing, we're going to put `Survivor - E14 - It All Boils Down to This` in `/share/CACHEDEV1_DATA/videos/Videos/TV Recordings/Survivor (2019)/Season 40/Survivor (2019) - S40E14 - It All Boils Down to This.mp4`
May 13, 2020 23:00:09.521 [0x7fda25ffb700] DEBUG - It took 60.000000 ms to retrieve 43 items.
May 13, 2020 23:00:09.558 [0x7fda73fff700] DEBUG - Assimilator: Moving "/share/CACHEDEV1_DATA/videos/Videos/TV Recordings/.grab/157ff26abfbaa01d4a11106325e9765b5e8cdff2-7f9f7b46b1f30e96a88eaba2808c869ec4e3f4a8/Survivor (2019) - S40E14 - It All Boils Down to This.mp4" to "/share/CACHEDEV1_DATA/videos/Videos/TV Recordings/Survivor (2019)/Season 40/Survivor (2019) - S40E14 - It All Boils Down to This.mp4"
May 13, 2020 23:00:09.559 [0x7fda73fff700] DEBUG - Assimilator: Moving "/share/CACHEDEV1_DATA/videos/Videos/TV Recordings/.grab/157ff26abfbaa01d4a11106325e9765b5e8cdff2-7f9f7b46b1f30e96a88eaba2808c869ec4e3f4a8/.nfs0000000011fc075800000017" to "/share/CACHEDEV1_DATA/videos/Videos/TV Recordings/Survivor (2019)/Season 40/.nfs0000000011fc075800000017"
May 13, 2020 23:00:09.559 [0x7fda73fff700] ERROR - Couldn't rename file "/share/CACHEDEV1_DATA/videos/Videos/TV Recordings/.grab/157ff26abfbaa01d4a11106325e9765b5e8cdff2-7f9f7b46b1f30e96a88eaba2808c869ec4e3f4a8/.nfs0000000011fc075800000017" to "/share/CACHEDEV1_DATA/videos/Videos/TV Recordings/Survivor (2019)/Season 40/.nfs0000000011fc075800000017": Device or resource busy
May 13, 2020 23:00:09.559 [0x7fda73fff700] DEBUG - Grabber: Operation for 'Survivor - E14 - It All Boils Down to This' on channel 2.1 completed with status error (Could not move recorded media to destination)

/share/CACHEDEV1_DATA/videos is an NFS location (NAS server).

This may need investigation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.