Plex

From miki
Jump to navigation Jump to search

Links

Install

Plex Media Player on Linux

See https://knapsu.eu/plex/. Use flatpak. Dependency on KDE [2].

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --if-not-exists kdeapps --from https://distribute.kde.org/kdeapps.flatpakrepo
flatpak remote-add --if-not-exists plex-media-player https://flatpak.knapsu.eu/plex-media-player.flatpakrepo
flatpak install plex-media-player tv.plex.PlexMediaPlayer

... doesn't seem to work great on Debian Buster at least.

Kodi Plex Add-On

  • Select add-on from videos add-on.
  • Sign in to account.
  • In settings, enable direct play and enable h265.
  • Optionally, set add-on to autostart when Kodi starts.

Configuration

See also Shield TV and Wolverine.

Plex App on NVidia Shield TV Pro

  • Audio Passthrough:
  • Set to HDMI because it amplifies AC3 audio.
  • Todo: Note that passthrough is not advised [3], so maybe we should reconsider that.
  • Video quality - Adjust automatically:
  • Currently set to OFF.
  • Todo: Does that influence the quality of transcode?

Plex Server

  • Server - Settings - Library - Disable media deletion.
  • Languages - Prefer subtitles in Français.

How-To

Fix film metadata / bad matching

  • Go in server library.
  • Select movie, then Fix match....

If movie has several versions available, and one of these is not correct:

  • Select first split apart.

See also this post about upgrading the matching agent.

Use Plex add-on in Kodi

Advantage of using the Kodi add-on is that it has (currently) better direct play support (in particular AC3 audio).

To install Plex add-on in Kodi [4],[5]:

  • Go to Kodi add-on menu
  • Select Download, Videos Add-Ons.
  • Select Plex.
  • Install.

Some settings to consider:

  • Make sure direct play is enabled.
  • Make sure H365 is enabled if supported.
  • Set plex add-on to autostart when Kodi starts (to avoid to navigate to that add-on every time).

Prevent transcode with AC3 / EAC3 audio on Nvidia Shield TV

Although the NVidia shield TV supports AC3 / EAC3 natively, it is transcoded by the support [6], [7]

To prevent that:

  • Use Plex add-on in Kodi, instead of the Plex app on the shield.
  • ???

More on DirectPlay:

Naming convention

References [8]

Recommended folder structure:

   /Media
      /Movies
         movie content
      /Music
         music content
      /TV Shows
         television content
Basic Naming - separate folder
   /Movies
      /Avatar (2009)
         Avatar (2009).mkv
      /Batman Begins (2005)
         Batman Begins (2005).mp4
         Batman Begins (2005).en.srt
         poster.jpg
Basic Naming - standalone files (slower scanning)
   /Movies
      Avatar (2009).mkv
      Batman Begins (2005).mp4
Split across multiple files
Use MovieName (release year) – Split_Name.ext, where Split_Name is cdX, discX, diskX, dvdX, partX or ptX.
   /Movies
      /The Dark Knight (2008)
         The Dark Knight (2008) - pt1.mp4
         The Dark Knight (2008) - pt2.mp4
Subtitles
Must enable the local media assets scanner. Recommended formats are SRT, SMI, SSA (or ASS).
Use
  • MovieName (Release Date).[Language_Code].ext or
  • Movies/MovieName (Release Date).[Language_Code].ext
  • Movies/MovieName (Release Date).[Language_Code].forced.ext
   /Movies
      Avatar (2009).mkv
      Avatar (2009).en.srt
   
   /Movies
      /Avatar (2009)
         Avatar (2009).mkv
         Avatar (2009).eng.ass

Troubleshooting

Collect logs

Plex Player

.Plex Server

  • Go to server page, manage, console or troubleshooting and click Download logs.

Rewind / FF issues

  • At least have that issue on Chrome / Debian Buster, with ShieldTV embedded player.
  • Trying fix:
  • Trying the official player from https://plex.tv, click launch.
  • Trying to enable Settings -> Plex Web -> Debug -> Use alternate streaming protocol for video playback. -> Much better!

30s startup delay

Symptoms:

  • Symptom: when launching media, 30s (32 in fact) of spinning wheel before media shows up. During that time, dashboard doesn't show any connection.
  • Relevant tickets [10], [11].
  • Seems to occur only when doing Direct Stream on the Plex App on Shieldh TV Pro.
  • When transcoding (can be forced by disabling HDMI passthrough on Plex App), delay is only 8s on Shield TV Pro.
  • Can't reproduce this anymore. Audio passthrough disabled doesn't trigger transcode when using AC3 anymore (saw a quick update message before playing the media).
  • On Web browser, delay is ~2s, direct or not.
  • On Kodi addon, delay is ~2s.

Summary:

  • The symptoms depend on:
  • Whether media is local or remote (SMB).
Local media means media on Shield TV Pro filesystem when using the Shield Plex serer, and media located on NAS filesystem when using the NAS Plex server.
  • Whether media container is MKV or MP4.
The type of MP4 (standard or web optimize) does not matter here (with respect to delay, direct play decision, or VOBSUB support).
  • Whether using the Plex App or Kodi add-on.
  • Without delay means ~2s.
  • In general remote or local, MP4 or MKV, with or without VOBSUB are always direct played without delay.
  • The exceptions are:
  • On Plex app, Remote MKV are direct play with 30s delay, and MP4 + VOBSUB are transcoded (with bad quality).
Transcode reason is Direct Play was attempted but failed, fallen back to transcoding.
  • On Kodi add-on, Remote MKV are direct play with 20s delay, or sometimes fail to play.
  • In conclusion, if we favor direct play anyway, our best bet is to use the Kodi add-on with the NAS Plex server.
  • But this means overloading the NAS with an additional process.
  • Kodi app is less remote friendly than the Plex app.

Some tests:

  • Select movie.
  • Select version
  • Play from start.
  • When Direct Play, try both Shield as server, and Wolverine.
  • Shield App:
  • Dec 26, 2020 17:33
  • 1080p, 1.9Mbps: Interstellar 1080p H264 AAC stereo .MP4: Direct Play AV, 3s (+SRT subtitles)
  • SD, 1.7Mbps: Interstellar 480p H264 AC3 5.1 .MKV: '
  • SD, 1.5Mbps: Interstellar 480p H264 AAC 5.1 .MKV: '
  • SD, 1.4Mbps: Interstellar 480p H265 AC3 5.1 .MKV: '
  • Dec 26, 2020 17:36:35
  • Shield Kodi:
  • Note: on Kodi, even when there is a delay, the play request shows up immediately on the dashboard. Looking in the log, we don't see the same 30s delay between the Content-Length requests.
  • Dec 26, 2020 17:37:51
  • 1080p, 1.9Mbps: Interstellar 1080p H264 AAC stereo .MP4: Direct Play AV, 3s (+SRT subtitles)
  • Note that in the logs, we see transcode messages, even though it direct plays.
    Dec 26, 2020 19:11:35.247 [4977] DEBUG - [Transcode] MDE: Interstellar (2014): no direct play video profile exists for http/mp4/h264
    Dec 26, 2020 19:11:35.247 [4977] DEBUG - [Transcode] MDE: Interstellar (2014): no direct play video profile exists for http/mp4/h264/aac
    Dec 26, 2020 19:11:35.247 [4977] DEBUG - [Transcode] MDE: Interstellar (2014): transcoding selected subtitle stream
    Dec 26, 2020 19:11:35.247 [4977] DEBUG - [Transcode] MDE: Interstellar (2014): selected media 0 / 183
  • SD, 1.7Mbps: Interstellar 480p H264 AC3 5.1 .MKV: Direct Play AV, 20s (+SRT subtitles!)
  • SD, 1.5Mbps: Interstellar 480p H264 AAC 5.1 .MKV: Direct Play AV, 20s (+SRT subtitles!)
  • SD, 1.4Mbps: Interstellar 480p H265 AC3 5.1 .MKV: '
  • Dec 26, 2020 17:40:24
  • Shield App with Shield Server:
  • Start — Dec 26, 2020 21:24:34
  • Delay One Brave-H264-AAC2ch.mkv: DP 30s (same with VOBSUB)
  • Delay Two Brave-H264-AAC2ch-mp4weboptim.m4v: DP 2s (no VOBSUB available :-( )
  • Delay Three Brave-H264-AAC5.1ch.mkv: DP 30s (same with VOBSUB)
  • Delay Four Brave-H264-AAC5.1ch-mp4weboptim.m4v: DP 2s (no VOBSUB available :-( )
  • Delay Five Brave-H264-AC32ch.mkv: DP 30s (same with VOBSUB)
  • Delay Six Brave-H264-AC32ch-mp4weboptim.m4v: DP 2s (no VOBSUB available :-( )
  • Delay Seven Brave-H264-AC35.1chpassthrough.mkv: DP 30s (same with VOBSUB)
  • Delay Eight Brave-H264-AC35.1chpassthrough-mp4weboptim.m4v: DP 2s (no VOBSUB available :-( )
  • Delay Nine Brave-H264-AC35.1chrecoded.mkv: DP 30s (same with VOBSUB)
  • Delay Ten Brave-H264-AC35.1chrecoded-mp4weboptim.m4v: DP 1s (no VOBSUB available :-( )
  • End — Dec 26, 2020 21:32:52
  • DelayTwo One - Bad Teacher-AAC2ch.mkv: DP 30s (same with VOBSUB)
  • DelayTwo Two - Bad Teacher-AAC2ch-mp4weboptim.m4v: DP 2s, but if playing VOBSUB, transcode V (and bad quality) (transcode reason: Direct Play was attempted but failed, fallen back to transcoding)
  • DelayTwo Three - Bad Teacher-AAC5.1ch-mp4weboptim.m4v: DP 2s, but if playing VOBSUB, transcode V (and bad quality) (transcode reason: Direct Play was attempted but failed, fallen back to transcoding)
  • DelayThree One - Brave - H264-AACstereo-MP4.m4v: DP 2s (Standard MP4) But if playing VOBSUB, transcode V (and bad quality) (transcode reason: Direct Play was attempted but failed, fallen back to transcoding)!
  • DelayThree Two - Brave - H264-AC3passthrough-MP4.m4v: DP 2s (Standard MP4). But if playing VOBSUB, transcode V (and bad quality) (transcode reason: Direct Play was attempted but failed, fallen back to transcoding)!
  • Shield App with Shield Server, with local library:
  • Bad Teacher H264 AC3 5.1.mkv: DP 2s (same with VOBSUB)
  • Shield Kodi with Shield Server:
  • Start — Dec 26, 2020 21:38:41
  • Delay One Brave-H264-AAC2ch.mkv: DP 20s, but DP 2s with local media.
  • Delay Two Brave-H264-AAC2ch-mp4weboptim.m4v: DP 2s
  • Delay Three Brave-H264-AAC5.1ch.mkv: DP 20s, but doesnt play (goes into Playing Next screen), but DP 2s with local media.
We get the following errors. But we get the same when it works, except the curl_easy_perform one.
   Dec 26, 2020 21:42:28.038 [10513] Error — Error issuing curl_easy_perform(handle): 28
   Dec 26, 2020 21:42:30.098 [10358] Error — [Transcode] ClientProfileExtra: missing protocol parameter
   Dec 26, 2020 21:42:30.098 [10358] Warning — [Transcode] ClientProfileExtra: ignoring directive: append-transcode-target-audio-codec(type=videoProfile&context=streaming&audioCodec=ac3)
   Dec 26, 2020 21:42:30.099 [10358] Warning — [Transcode] TranscodeUniversalRequest: at least one profile extra directive could not be read
   Dec 26, 2020 21:42:51.601 [10633] Error — Unknown metadata type: folder
   Dec 26, 2020 21:42:51.693 [10634] Warning — SLOW QUERY: It took 210.000000 ms to retrieve 51 items.
  • Delay Four Brave-H264-AAC5.1ch-mp4weboptim.m4v: DP 2s
  • Delay Five Brave-H264-AC32ch.mkv: DP 20s, but doesnt play.
  • Delay Six Brave-H264-AC32ch-mp4weboptim.m4v: DP 2s
  • Delay Seven Brave-H264-AC35.1chpassthrough.mkv: DP 20s, but doesnt play.
  • Delay Eight Brave-H264-AC35.1chpassthrough-mp4weboptim.m4v: DP 2s
  • Delay Nine Brave-H264-AC35.1chrecoded.mkv: DP 20s, but doesnt play.
  • Delay Ten Brave-H264-AC35.1chrecoded-mp4weboptim.m4v: DP 2s
  • End — Dec 26, 2020 21:54:33
  • DelayTwo One - Bad Teacher-AAC2ch.mkv: DP 20s
  • DelayTwo Two - Bad Teacher-AAC2ch-mp4weboptim.m4v: DP 2s
  • DelayTwo Three - Bad Teacher-AAC5.1ch-mp4weboptim.m4v: DP 2s
  • DelayThree One - Brave - H264-AACstereo-MP4.m4v: DP 2s (MP4 but not web optimized). If playing VOBSUB, DP 2s also!
  • DelayThree Two - Brave - H264-AC3passthrough-MP4.m4v: DP 2s (MP4 but not web optimized). If playing VOBSUB, DP 2s also!
  • Shield App with Shield Server, with HDMI passthrough disabled:
  • ... This was our trick to trigger anymore when using AC3, but this doesn't work anymore.
  • Shield App with Synology Server:
  • End — Dec 26, 2020 23:09:xx
  • Delay One to Ten: Direct Play 2s delay. Same with VOBSUB.
  • End — Dec 26, 2020 23:11:45
  • DelayThree One - Brave - H264-AACstereo-MP4.m4v: DP 2s (MP4 but not web optimized) But if playing VOBSUB, Cannot play media (because transcode disabled)!
  • DelayThree Two - Brave - H264-AC3passthrough-MP4.m4v: DP 2s (MP4 but not web optimized). But if playing VOBSUB, Cannot play media (because transcode disabled)!
  • Shield Kodi with Synology Server:
  • Start — Dec 26, 2020 23:15:21
  • Delay One to Ten: Direct Play 2s delay. Same with VOBSUB.
  • End — Dec 26, 2020 23:18:35
  • DelayTwo One - Bad Teacher-AAC2ch.mkv: DP 2s (same with VOBSUB)
  • DelayTwo Two - Bad Teacher-AAC2ch-mp4weboptim.m4v: DP 2s (same with VOBSUB)
  • DelayTwo Three - Bad Teacher-AAC5.1ch-mp4weboptim.m4v: DP 2s (same with VOBSUB)
  • DelayThree One - Brave - H264-AACstereo-MP4.m4v: DP 2s (MP4 but not web optimized). If playing VOBSUB, DP 2s also!
  • DelayThree Two - Brave - H264-AC3passthrough-MP4.m4v: DP 2s (MP4 but not web optimized). If playing VOBSUB, DP 2s also!

Relevant logs analysis:

  • We get a Failed to stream media, client probably disconnected after 5505024 bytes: 104 - Connection reset by peer. Initially thought it was linked to 30s delay, but we get it everytimes.
49122:Dec 26, 2020 16:53:12.388 [22929] DEBUG - Auth: authenticated user 1 as m.xelp@immie.org
49123:Dec 26, 2020 16:53:12.388 [32247] DEBUG - Request: [192.168.1.88:42344 (Subnet)] GET /library/parts/12486/1608848836/file.mkv?autoAdjustQuality=0&hasMDE=1&location=lan&mediaBufferSize=74944 (8 live) TLS Signed-in Token (m.xelp@immie.org) (range: bytes=0-) 
49124:Dec 26, 2020 16:53:12.404 [32247] DEBUG - Content-Length of /storage/WOLVERINE/family/movie/_tests/Interstellar (2014) - x265.mkv is 1746637281 (of total: 1746637281).
49125:Dec 26, 2020 16:53:12.620 [22929] DEBUG - Auth: authenticated user 1 as m.xelp@immie.org
49126:Dec 26, 2020 16:53:12.620 [31709] DEBUG - Request: [192.168.1.88:42346 (Subnet)] GET /library/parts/12486/1608848836/file.mkv?autoAdjustQuality=0&hasMDE=1&location=lan&mediaBufferSize=74944 (9 live) TLS Signed-in Token (m.xelp@immie.org) (range: bytes=1746378705-) 
49127:Dec 26, 2020 16:53:12.626 [31709] DEBUG - Content-Length of /storage/WOLVERINE/family/movie/_tests/Interstellar (2014) - x265.mkv is 258576 (of total: 1746637281).
49128:Dec 26, 2020 16:53:42.665 [22929] DEBUG - Failed to stream media, client probably disconnected after 5505024 bytes: 104 - Connection reset by peer
49129:Dec 26, 2020 16:53:42.665 [22929] DEBUG - Completed after connection close: [192.168.1.88:42344] 206 GET /library/parts/12486/1608848836/file.mkv?autoAdjustQuality=0&hasMDE=1&location=lan&mediaBufferSize=74944 (7 live) TLS 30276ms 5505024 bytes (range: bytes=0-) 
49130:Dec 26, 2020 16:53:42.680 [22929] DEBUG - Completed: [192.168.1.88:42346] 206 GET /library/parts/12486/1608848836/file.mkv?autoAdjustQuality=0&hasMDE=1&location=lan&mediaBufferSize=74944 (7 live) TLS 30059ms 258576 bytes (range: bytes=1746378705-) 
49131:Dec 26, 2020 16:53:42.780 [22929] DEBUG - Auth: authenticated user 1 as m.xelp@immie.org
49132:Dec 26, 2020 16:53:42.781 [31709] DEBUG - Request: [192.168.1.88:42350 (Subnet)] GET /library/parts/12486/1608848836/file.mkv?autoAdjustQuality=0&hasMDE=1&location=lan&mediaBufferSize=74944 (7 live) TLS Signed-in Token (m.xelp@immie.org) (range: bytes=5006-) 
49133:Dec 26, 2020 16:53:42.795 [31709] DEBUG - Content-Length of /storage/WOLVERINE/family/movie/_tests/Interstellar (2014) - x265.mkv is 1746632275 (of total: 1746637281).
49134:Dec 26, 2020 16:53:43.252 [22929] DEBUG - Auth: authenticated user 1 as m.xelp@immie.org
49135:Dec 26, 2020 16:53:43.252 [31709] DEBUG - Request: [192.168.1.88:42352 (Subnet)] POST /playQueues?includeChapters=1&continuous=0&includeLoudnessRamps=1&repeat=0&extrasPrefixCount=0&type=video&shuffle=0&uri=server%3A%2F%2F315dbe1ac5eab4b3b25956e1907bba687927fecf%2Fcom.plexapp.plugins.library%2Flibrary%2Fmetadata%2F183&key=%2Flibrary%2Fmetadata%2F183 (7 live) TLS GZIP Signed-in Token (m.xelp@immie.org)
  • When on Kodi Add-on, we get this msg every 5s, even when no movie playing:
   Dec 26, 2020 17:39:52.399 [22928] DEBUG - Auth: authenticated user 1 as m.xelp@immie.org
   Dec 26, 2020 17:39:52.399 [2609] DEBUG - Request: [192.168.1.61:59608 (Subnet)] GET /statistics/bandwidth?timespan=6 (17 live) GZIP Signed-in Token (m.xelp@immie.org)
   Dec 26, 2020 17:39:52.411 [22928] DEBUG - Completed: [192.168.1.61:59608] 200 GET /statistics/bandwidth?timespan=6 (17 live) GZIP 12ms 1514 bytes (pipelined: 19)
  • When streaming ends, we get:
   Dec 26, 2020 21:57:29.759 [11396] DEBUG — Streaming Resource: Terminated session 0x29fdd71598:440ac09a-635c-4e98-971b-720a0905387e with reason Client stopped playback.

Relevant client log:

   12-28 18:29:37.154  i: [FFmpeg] [INFO] [Cache] Opening source from https://192-168-1-88.ab962241bee7454183355a238f9372ef.plex.direct:32400/library
   /parts/12474/1608832489/file.mkv?autoAdjustQuality=0&hasMDE=1&location=lan&mediaBufferSize=74944&X-Plex-Client-Identifier=46693b1320189a6d-com-ple
   xapp-android&X-Plex-Client-Platform=Android&X-Plex-Device=SHIELD%20Android%20TV&X-Plex-DRM=widevine%3Avideo&X-Plex-Platform=Android&X-Plex-Platfor
   m-Version=9&X-Plex-Product=Plex%20for%20Android%20(TV)&X-Plex-Token=...UX5q&X-Plex-Version=8.11.0.22186.
   12-28 18:29:37.358  i: [FFmpeg] [INFO] [Cache] Cache is enabled, connecting cache context.
   12-28 18:29:37.470  i: [FFmpeg] [INFO] [Cache] Worker thread has been enabled and will start processing data.
   12-28 18:29:37.479  i: [FFmpeg] [INFO] [Cache] Source seek requested to 1725850017 bytes with 0 whence.
   12-28 18:29:37.480  i: [FFmpeg] [INFO] [Cache] Seek found to 1725850017 bytes.
   12-28 18:29:40.459  i: [HttpServer] /192.168.1.61:38690 - GET /logging
   12-28 18:30:07.725  i: [FFmpeg] [INFO] [Cache] Seek complete to 1725850017 bytes.
   12-28 18:30:07.725  i: [FFmpeg] [INFO] [Cache] Seek has returned with a response of 1725850017.
   12-28 18:30:07.735  i: [FFmpeg] [INFO] [Cache] Source seek requested to 7059 bytes with 0 whence.
   12-28 18:30:07.737  i: [FFmpeg] [INFO] [Cache] Seek found to 7059 bytes.
   12-28 18:30:07.868  i: [FFmpeg] [INFO] [Cache] Seek complete to 7059 bytes.
   12-28 18:30:07.869  i: [FFmpeg] [INFO] [Cache] Seek has returned with a response of 7059.

Relevant analysis:

  • When using MP4 (web optimized) container, there is no thumbnail when movie is not identified, but there is one when using .MKV container.
  • AC3/AAC loudness difference:
  • With HDMI passthrough, loudness is bigger for AC3 than for AAC. When HDMI passthrough is disabled, AC3 and AAC have same loudness, which is same as AAC with HDMI passthrough.
  • This doesn't occur with Kodi add-on (probably because no HDMI passthrough).

MP4 container with VOBSUB subtitles triggers transcode

Test case: any DVD converted with Handbrake, using e.g. MP4 container, H264, any audio, VOBSUB subtitles.

MKV container with PGC subtitles triggers transcode

Test case: [zza]Lucy.2014.BDRIP.1080p.x265.AC3.mkv.

Quality quite bad when transcoding on Shield

  • transcoding quality is quite low (using shield plex app and shield plex server)
  • Note: in App, Video Quality, Adjust automatically is set to OFF, but Home streaming is set to Maximum.

Miscellaneous issues

  • 'Enhanced' - French SRT subtitles not showing
  • Because the SRT file was empty / corrupted.
  • 'Lucy' - Cannot play AC3 audio. Turns out there was an issue in that track anyway (delay).
  • Keep transcoding AC3 media.
  • Does not seem to be the case in our DVD tests. The delay is due to something else.
  • When transcoding on Shield TV server, the quality is quite bad. Why can't we boost the quality of the transcode to the max (say 4Mb)?
Ghost in the Shell (Anime)
  • Direct Play without subtitles, but transcode with subtitles.
  • MP4, but still 30s delay when using shield server.
Lucy
  • File [zza]Lucy.2014.BDRIP.1080p.x265.AC3.mkv, MKV, H265, AC3 audio, PGS and SRT subtitles.
  • Note that file has serious audio delay issues.
  • Playing with PGS subtitles trigger transcode, which fails (so transcode not due to using AC3 as initially thought [12], [13]).
1382:Dec 20, 2020 00:42:18.545 [23009] DEBUG - [Transcode] MDE: Lucy (2014): Direct Play is disabled
1383:Dec 20, 2020 00:42:18.545 [23009] DEBUG - [Transcode] MDE: Lucy (2014): media must be transcoded in order to use the hls protocol
  • Workaround:
  • Plex addon on Kodi [14].

To Do

  • Shield TV - Play with Shield audio passthrough settings. See if that enables the direct play of AC3.