Stuttering on playback on Linux client

I’m running the latest server and client on an Ubuntu 16.04 LTS. I built the client from source following the instructions in the README, but the performance is not great.

Interestingly enough this server works fine with any MacOS or Windows client, including laptops on my local wifi.

Possibly try this one as a point of comparison to see if you experience the same problem. I use the AppImage version on Mint and haven’t observed stuttering.

Hi, thanks for your reply. I did in fact try out this app at first. It’s performance seemed slightly worse.

Here are the specs of my machine. It’s a Haswell-based Gigabyte BRIX:

System:    Host: htpc Kernel: 4.15.0-55-generic x86_64 (64 bit) Console: tty 3 Distro: Linux Mint 18.3 Sylvia
Machine:   Mobo: GIGABYTE model: MMLP5AP-00 v: 1.x Bios: American Megatrends v: F6 date: 12/08/2014
CPU:       Dual core Intel Core i5-4200U (-HT-MCP-) cache: 3072 KB
           clock speeds: max: 2600 MHz 1: 2269 MHz 2: 2012 MHz 3: 1954 MHz 4: 2015 MHz
Graphics:  Card: Intel Haswell-ULT Integrated Graphics Controller
           Display Server: X.org 1.18.4 drivers: intel (unloaded: fbdev,vesa)
           tty size: 155x37 Advanced Data: N/A out of X
Audio:     Card-1 Intel 8 Series HD Audio Controller driver: snd_hda_intel Sound: ALSA v: k4.15.0-55-generic
           Card-2 Intel Haswell-ULT HD Audio Controller driver: snd_hda_intel
Network:   Card-1: Realtek RTL8723AE PCIe Wireless Network Adapter driver: rtl8723ae
           IF: wlan0 state: down mac: 24:0a:64:b6:23:ba
           Card-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver: r8169
           IF: eth0 state: up speed: 1000 Mbps duplex: full mac: 74:d4:35:42:c7:40
Drives:    HDD Total Size: 120.0GB (24.2% used) ID-1: /dev/sda model: Crucial_CT120M50 size: 120.0GB
Partition: ID-1: / size: 103G used: 20G (21%) fs: ext4 dev: /dev/sda1
           ID-2: swap-1 size: 8.50GB used: 0.00GB (0%) fs: swap dev: /dev/sda5
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 60.0C mobo: 27.8C
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 212 Uptime: 23:34 Memory: 1639.5/7896.7MB Init: systemd runlevel: 5
           Client: Shell (bash) inxi: 2.2.35

I suspect you may have also already tried these, but here are a few random troubleshooting thoughts that might help confirm it is the PMP vs something specific with rendering video on that hardware. Perhaps something will pop:

  • Do you get the same behavior using the player in the Plex web client in a web browser on that box?
  • While a video is playing, check the Plex dashboard to see if it is Direct Play/Direct Stream/Transcoding. Is this the same as when the same video is played from MacOS or Win?
  • Do you have the same problem if you play the media directly in another player on the server? (VLC?)
  • Is it specific to a specific encoding/container type, or all files? Perhaps only mpeg2 in a .ts container, only h.264 in .mp4? Only live TV, or recordings?
  • What is the server “doing” (CPU use, etc) while playing - system monitor, top, htop, etc. I doubt it, but with the server and client on the same box is it maxing out something while playing?

I saw somewhat similarly bad behavior. Of course, the usage profile will be dominated by the browser in this case.

I am ensuring that I’m playing the original stream, so no transcoding is happening.

No, I play media directly using Kodi (mostly) decoding high bit-rate files of various types including transcoding audio formats newer than AC-3 (since my preamp is limited to that), and things work OK. The load does go up frequently, but the video is responsive.

I’m mostly testing the Live TV & DVR functionality, so I’m not sure (yet). I’m interested in replacing a dead TiVo.

FYI, here’s what the machine was doing part of the time:

top - 15:45:34 up 19 days, 18:28,  4 users,  load average: 1.16, 0.44, 0.41
Tasks: 240 total,   3 running, 183 sleeping,   0 stopped,   1 zombie
%Cpu(s): 31.4 us,  4.7 sy,  0.0 ni, 63.6 id,  0.2 wa,  0.0 hi,  0.2 si,  0.0 st
KiB Mem :  8086232 total,   942052 free,  3756640 used,  3387540 buff/cache
KiB Swap:  8304636 total,  8304636 free,        0 used.  3775968 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
24155 clint     20   0 2183692 222428  48752 R  59.1  2.8 333:31.44 cinnamon
 9120 clint     20   0 3678348 511512 115472 S  53.8  6.3   0:46.72 plexmediaplayer
 9233 clint     20   0 1263500 187700  84360 R  19.6  2.3   0:29.49 QtWebEngineProc
 1547 root      20   0  393196  88048  74824 S   3.3  1.1 283:12.26 Xorg
22123 clint     20   0   58604  13244   3544 S   2.0  0.2 127:32.33 mosh-server
 4978 plex      20   0 3091072 1.208g  24652 S   1.7 15.7  32:55.21 Plex Media Serv

So as you can see, the load is not astronomical, but the result is lackluster.

I didn’t see the load go up too badly recording two late night talk shows directly to a NAS via NFS.

Incidentally, while the video playback works OK on a 2015 Macbook Pro w/16G RAM, I see the client place an unreasonable strain on it when it starts up. The fan kicks on and everything even when it’s not playing any media. What in the heck is it doing?

So, if I had to place any blame, I’d say the client is somehow very inefficient.

Your cinnamon process CPU usage looks high to me, which is interesting because that is your desktop/UI process. Is it high all the time, or only when running PMP? My cinnamon process doesn’t run anywhere near 60% - more like 6% while PMP is playing something. A couple things to try:

  • Reboot and see if the high cinnamon CPU and the problem persists. Alternately do a “cinnamon --replace” from the command line to replace the cinnamon process (but I’ve have some problems with replace)
  • When logging into your computer, click on the icon next to your login name. Is “Cinnamon (Default)” selected, or “Cinnamon (Software Rendering)”? If software rendering is selected, then that may be the problem. I’m guessing this is the same for Cinnamon on Ubuntu as I see on Mint.

I can’t speak to MacOS, but I see a short bump in CPU usage when starting PMP, another when I select the live TV guide, but then it drops to very low until I start playing something. While playing CPU usage stays level at ~20-25%.

image

This is PMP on Mint also on an i5 laptop. I don’t run PMS on this box, but if you are direct play or direct stream the PMS usage should be low, which we are seeing in your screen snapshot - PMS is using 1.7% CPU. I wouldn’t expect recording to create much demand from PMS. Once it makes the API call to the tuner, while recording it is pretty much just redirecting the data stream to your disk.

OK, I have seen that software rendering warning, but that was back when I was trying to get Xorg configured correctly. I couldn’t tell which desktop env was selected, but I did explicitly select Cinnamon, and this is what things look like now:

top - 08:27:32 up 1 day, 13:48,  4 users,  load average: 2.12, 1.12, 0.51
Tasks: 218 total,   1 running, 167 sleeping,   0 stopped,   0 zombie
%Cpu(s): 19.2 us,  4.2 sy,  0.0 ni, 76.2 id,  0.5 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8086232 total,   131500 free,  2222344 used,  5732388 buff/cache
KiB Swap:  8304636 total,  8304636 free,        0 used.  5354488 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
17017 clint     20   0 3701640 510612 115072 S  57.8  6.3   2:20.44 plexmediaplayer
17135 clint     20   0 1255444 188868  81340 S  19.6  2.3   0:52.33 QtWebEngineProc
15600 clint     20   0 1709924 111380  51928 S   4.7  1.4   0:15.98 cinnamon
13427 root      20   0  364980  55620  46128 S   3.3  0.7   0:17.12 Xorg
 5855 clint     20   0   56544  10552   2772 S   1.7  0.1  24:46.41 mosh-server
 1188 plex      20   0 2975904 842108  26624 S   0.7 10.4  20:16.19 Plex Media Serv

So, that may have corrected the high Cinnamon process. It was only high when running the media player.

I still see video “jankiness” in playback however.

Someone on the Mint forums gave me a cluepon on how to enable vdpauinfo. This provided some interesting info.

libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_40
libva info: va_openDriver() returns 0
display: :0   screen: 0
API version: 1
Information string: OpenGL/VAAPI/libswscale backend for VDPAU

Video surface:

name   width height types
-------------------------------------------
420     1920  1080  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 
422     1920  1080  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 
444     1920  1080  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 

Decoder capabilities:

name                        level macbs width height
----------------------------------------------------
H264_BASELINE                  51 16384  2048  2048
H264_MAIN                      51 16384  2048  2048
H264_HIGH                      51 16384  2048  2048
H264_CONSTRAINED_BASELINE      51 16384  2048  2048

Output surface:

name              width height nat types
----------------------------------------------------
B8G8R8A8         16384 16384    y  
R8G8B8A8         16384 16384    y  
R10G10B10A2      16384 16384    y  
B10G10R10A2      16384 16384    y  
A8               16384 16384    y  

One thing missing here is MPEG2 native support. I removed unsupported codecs. Could this be why things are bad for me watching raw stream TV?

I should mention this doesn’t entirely match what I’m seeing from vainfo:

libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_40
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.40 (libva )
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Mobile - 1.8.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD

MPEG2 is mentioned here, but it’s not clear why the vdpauinfo says unsupported.

Grrr…I was really hopeful that would resolve it. Still, it is good to be off software rendering - it gives you more horsepower for other things.

Try playing around with the settings in PMP. Click on the settings icon image in the upper right, then click on the “Show Advanced” button. Click “Debug” on the left and try turning off direct play (so it should direct stream). Try turning off both direct play and direct stream to force it to transcode. Under “Quality” on the left, then under “Home Streaming”, turn off “Use Recommended Settings” and try setting the video quality to something less than “Maximum”. You can always set these back if no joy.

I (thankfully) haven’t had this problem, but I do see threads where others do. Some have been able to find a combination of these settings that gets rid of the jerkiness.

Unfortunately, the transcoding options (particularly at 1080) either look bad from compression or worse have motion artifacts. The only one that looked reasonable was 4Mbps 720p. So, transcoding doesn’t look like a decent solution. The direct stream result was better.

I’m out of ideas, but there is a lot of good information in this thread. Perhaps someone else has insight?

1 Like

Thanks a lot for bearing with me and coming up with suggestions!

FYI, here’s the Mint Forum conversation I was having which had useful info on vainfo and friends. It turns it looks like I do have native MPEG2 support, it’s just that the other library mentioned in there isn’t as up to date.

https://forums.linuxmint.com/viewtopic.php?f=59&t=299375&p=1669887#p1669887

Before one speaks too much and theorizes what the problem is, more information is needed:

  1. The XML of the item actually being played (Hover over it - expose ellipsis - Get info - View XML - paste surrounded with ``` on the preceding and succeeding lines.
this is how it looks when done 
  1. DEBUG (not VERBOSE) mode logs collected by:
    a. Verify log settings
    b. Start Playback
    c. Play for 30 seconds / until stutters
    d. Stop Playback
    e. Wait 30 seconds for logs to flush
    f. Settings - Server - Troubleshooting - Download Logs
    g. attach the ZIP file

Also, be advised, PMP on Linux is not an official Plex player so there will be limits as to what we can do here.
ref: https://www.plex.tv/media-server-downloads/#plex-app

<Video ratingKey="1296" key="/library/metadata/1296" skipParent="1" grandparentRatingKey="1281" guid="com.plexapp.agents.thetvdb://289574/4/191?lang=en" parentGuid="com.plexapp.agents.thetvdb://289574/4?lang=en" grandparentGuid="com.plexapp.agents.thetvdb://289574?lang=en" librarySectionTitle="TV Shows" librarySectionID="2" librarySectionKey="/library/sections/2" type="episode" title="Special Guest TBA" grandparentKey="/library/metadata/1281" grandparentTitle="The Late Show with Stephen Colbert" parentTitle="Season 4" contentRating="TV-14" summary="Stephen welcomes a special guest." index="191" parentIndex="4" viewOffset="693000" viewCount="1" lastViewedAt="1565364912" year="2019" thumb="/library/metadata/1296/thumb/1565336236" art="/library/metadata/1281/art/1565336236" parentThumb="/library/metadata/1282/thumb/1565336236" grandparentThumb="/library/metadata/1281/thumb/1565336236" grandparentArt="/library/metadata/1281/art/1565336236" grandparentTheme="/library/metadata/1281/theme/1565336236" duration="3718773" originallyAvailableAt="2019-08-08" addedAt="1565336223" updatedAt="1565336236">
<Media id="2002" duration="3718773" bitrate="25472" width="1920" height="1080" aspectRatio="1.78" audioChannels="6" audioCodec="ac3" videoCodec="mpeg2video" videoResolution="1080" container="mpegts" videoFrameRate="NTSC" channelIdentifier="6.1" mediaGrabBeginsAt="1565332500" mediaGrabDevice="device://tv.plex.grabbers.hdhomerun/10668024" mediaGrabStatus="complete" origin="dvr" videoProfile="main">
<Part accessible="1" exists="1" id="2002" key="/library/parts/2002/1565336222/file.ts" duration="3718773" file="/mnt/htpc/TV Shows/The Late Show With Stephen Colbert (2019)/Season 04/The Late Show With Stephen Colbert (2019) - S04E191 - Niecy Nash.ts" size="6565288060" container="mpegts" deepAnalysisVersion="4" packetLength="188" requiredBandwidths="14465,14116,13656,13656,13656,13656,13656,13656" videoProfile="main">
<Stream id="3779" streamType="1" codec="mpeg2video" index="0" bitrate="12416" bitDepth="8" chromaLocation="left" chromaSubsampling="4:2:0" closedCaptions="1" colorRange="tv" frameRate="29.970" height="1080" level="4" profile="main" refFrames="1" requiredBandwidths="13825,13476,13029,13029,13029,13029,13029,13029" scanType="interlaced" streamIdentifier="256" width="1920" displayTitle="1080i (MPEG2VIDEO)"/>
<Stream id="3781" streamType="2" selected="1" codec="ac3" index="1" channels="6" bitrate="448" language="English" languageCode="eng" audioChannelLayout="5.1(side)" requiredBandwidths="448,448,448,448,448,448,448,448" samplingRate="48000" streamIdentifier="257" displayTitle="English (AC3 5.1)"/>
<Stream id="3782" streamType="2" codec="ac3" index="2" channels="2" bitrate="192" language="Español" languageCode="spa" audioChannelLayout="stereo" requiredBandwidths="192,192,192,192,192,192,192,192" samplingRate="48000" streamIdentifier="258" displayTitle="Español (AC3 Stereo)"/>
<Stream id="3780" streamType="3" codec="eia_608" index="0" bitrate="12416" embeddedInVideo="1" requiredBandwidths="13825,13476,13029,13029,13029,13029,13029,13029" streamIdentifier="256" displayTitle="Unknown (EIA_608)"/>
</Part>
</Media>
<Genre id="6318" filter="genre=6318" tag="Other"/>
<Extras size="0"> </Extras>
</Video>
</MediaContainer>

I generated this after scrubbing the timeline a bit to get into the intro of the show where things start moving fast and and the stuttering is worse.

Plex Media Server Logs_2019-08-09_17-27-58.zip (3.8 MB)

Thank you for the logs. There is some unformate news

  1. The processor is only a dual core. PMS server machines are much better as quad cores if no Hardware Transcoding is enabled.

  2. What happens when you do try H.264 ? Does it play and transcode correctly?

Your logs show, which I do expect, no HW acceleration for Mpeg2. What I would also expect, which I’m not seeing, is that the hardware was detected albeit not used for MPEG2.

I refer to this block from the logs:

Aug 09, 2019 11:06:07.804 [0x7f78997fa700] ERROR - Unable to find title for item of type 5
Aug 09, 2019 11:06:07.804 [0x7f78997fa700] DEBUG - MDE: analyzing media item -1
Aug 09, 2019 11:06:07.804 [0x7f78997fa700] DEBUG - MDE: : no direct play video profile exists for http/mpegts/
Aug 09, 2019 11:06:07.804 [0x7f78997fa700] DEBUG - MDE: : no direct play video profile exists for http/mpegts//
Aug 09, 2019 11:06:07.805 [0x7f78997fa700] DEBUG - MDE: : codec is unavailable for analysis
Aug 09, 2019 11:06:07.805 [0x7f78997fa700] DEBUG - MDE: : codec is unavailable for analysis
Aug 09, 2019 11:06:07.805 [0x7f78997fa700] ERROR - Unable to find title for item of type 5
Aug 09, 2019 11:06:07.805 [0x7f78997fa700] DEBUG - MDE: : selected media 0 / -1
Aug 09, 2019 11:06:07.805 [0x7f78997fa700] DEBUG - Cleaning directory for session 25a5fbdb-a4a6-49a8-92c6-a0fd14893249 ()
Aug 09, 2019 11:06:07.805 [0x7f78997fa700] DEBUG - Starting a transcode session 25a5fbdb-a4a6-49a8-92c6-a0fd14893249 at offset -1.0 (state=3)
Aug 09, 2019 11:06:07.805 [0x7f78997fa700] DEBUG - Streaming Resource: Added session 0x7f7864615320:25a5fbdb-a4a6-49a8-92c6-a0fd14893249
Aug 09, 2019 11:06:07.806 [0x7f78997fa700] DEBUG - TPU: hardware transcoding: enabled, but no hardware decode accelerator found
Aug 09, 2019 11:06:07.806 [0x7f78997fa700] DEBUG - TPU: hardware transcoding: final decoder: , final encoder: 

Interesting. You are certainly correct that this is a dual-core machine. Inxi -F confirms this:

CPU:       Dual core Intel Core i5-4200U (-HT-MCP-) cache: 3072 KB
           clock speeds: max: 2600 MHz 1: 936 MHz 2: 1183 MHz 3: 1104 MHz 4: 1260 MHz

I am surprised at the lack of h/w support. Vainfo seems to indicate it has h/w encode/decode for MPEG2 & H.264. I included that output in a previous post above: Stuttering on playback on Linux client. What library do you use to detect this support? Or is that proprietary?

It will transcode, but the performance is worse, especially for 1080 streams. The result was OK for a 720p stream @4Mbps. Everything else was pretty janky. It does say (h/w) when the transcode is happening.

In the end while I know this is supposed to be an inexpensive PC, I am surprised a Haswell isn’t enough poop to make this all work.

Plex brings everyrthing it needs with it but remember, Plex is the server.
PMP is the player (client).

Are you using the Knapsu PMP client he builds for Linux from the public PMP sources?

also,

please go obtain a directory listing of ls -la /dev/dri and see what we have for owner and group.

Next please see which groups Plex is a member of. I am suspecting a permission problem because PMS will use the ASIC, and send to the player regardless what that player is.

To confirm, ark.intel.com confirms the presence of quick sync video (QSV) which is how Plex’s transcoding works.

I did try Knapsu’s client and had similar performance, maybe a bit worse. I built this using the instructions packaged with PMP and mpv.

Here’s the output of the listing

drwxr-xr-x   2 root root        80 Aug  7 18:39 .
drwxr-xr-x  20 root root      4120 Aug  9 08:19 ..
crw-rw----+  1 root video 226,   0 Aug  9 20:35 card0
crw-rw----+  1 root video 226, 128 Aug  7 18:39 renderD128
$ groups plex
plex : plex video

Let me know if something seems buggered up and I’ll try to fix it.