Safari and direct HEVC playback causes high CPU usage for Server

Server Version#:1.16.1.1246 (applies to all recent versions of server though)
Player Version#: 3.95.2 (Web client)

OS: macOS Mojave 10.14.5

Hello,

Safari on macOS High Sierra and later can play HEVC files.
If one drops an mp4 file with hevc video into Safari, the file plays back normally.

By making a custom Safari.xml profile in the Application Support folder, I was able to make Safari direct play such files, no transcoding necessary, and that worked well for the most part, with the VTDecoderXPCService process at ~30% cpu usage (on a 4-core i7 cpu and no hardware hevc decoding)

For the past couple of months (sorry can’t remember exactly at which version, but problems still persist) two things happen:

  • When the container is mkv, the cpu usage is at a constant 100% use for the Plex Media Server process (and VTDecoderXPCService at ~30% as usual)
  • When the container is mp4 (same file repackaged with Subler.app, not transcoded) the Plex Media Server process acts normal (no significant cpu usage) and VTDecoderXPCService process acts normal as well - but resume won’t work (!) with those files in Plex Web; they always start from the beginning.

Plex Transcoder process is almost idle in all cases (~0.2% cpu)

Playback is ok, perfectly good but constant 100% cpu usage for mkv gets things hot and fans spinning. And lack of resume for mp4 makes this a non-option.

My target is to direct play/stream in Safari (no transcoding video) which has great PiP support, so PMP is not a preferred option when using Plex on my Mac. I would also prefer to keep files as mkv, and not convert them, but that’s less important. I also think that this was not an issue a few months ago; I didn’t notice any fans spinning or high cpu usage, but then again I don’t have any actual data on that.

If any log files are needed, I can provide them.
Thanks!


Some additional info:

Safari.xml:

<?xml version="1.0" encoding="utf-8"?>
<Client name="Safari">
  <!-- Author: Plex Inc. -->
  <TranscodeTargets>
    <VideoProfile protocol="hls" container="mpegts" codec="h264,hevc,mpeg4" audioCodec="he-aac,aac,mp3" subtitleCodec="eia_608_embedded,webvtt" context="streaming">
      <Setting name="HlsExtraMultiChannelAudioStream" value="ac3" />
    </VideoProfile>
    <VideoProfile protocol="dash" container="mp4" codec="h264,hevc,mpeg4" audioCodec="he-aac,aac" subtitleCodec="eia_608_embedded,webvtt" context="streaming">
      <Setting name="ForceTranscodesForLive" value="false" />
      <Setting name="SkipAudioBeforeStart" value="true" />
      <!-- <Setting name="BreakNonKeyframes" value="true" />  -->
    </VideoProfile>
    <VideoProfile protocol="http" container="mp4" codec="h264,hevc,mpeg4" audioCodec="he-aac,aac,mp3" subtitleCodec="eia_608_embedded,webvtt" context="streaming">
      <Setting name="HlsExtraMultiChannelAudioStream" value="ac3" />
    </VideoProfile>
    <MusicProfile container="mp3" codec="mp3" />
    <PhotoProfile container="jpeg" />
    <SubtitleProfile container="ass,webvtt,srt" subtitleCodec="ass,webvtt,srt" context="all" />
  </TranscodeTargets>
  <CodecProfiles>
    <VideoCodec name="*">
      <Limitations>
        <UpperBound name="video.bitDepth" value="10" />
      </Limitations>
    </VideoCodec>
    <VideoAudioCodec name="*">
      <Limitations>
        <UpperBound name="audio.channels" value="6" />
      </Limitations>
    </VideoAudioCodec>
  </CodecProfiles>
  <!-- When transcoding a multi-channel audio stream inside a video transcode, downmix the audio stream to stereo. -->
  <TranscodeTargetProfiles>
    <VideoTranscodeTarget protocol="*" context="streaming">
      <VideoAudioCodec name="*">
        <Limitations>
          <UpperBound name="audio.channels" value="2" onlyTranscodes="true" />
        </Limitations>
      </VideoAudioCodec>
    </VideoTranscodeTarget>
  </TranscodeTargetProfiles>
</Client>

Mediainfo for mkv file that causes high cpu usage:

General
Unique ID                                : 190617415140147710755752214894411200574 (0x8F67942A889627B096FB238E36CF383E)
Format                                   : Matroska
Format version                           : Version 4
File size                                : 909 MiB
Duration                                 : 57mn 27s
Overall bit rate                         : 2 211 Kbps
Encoded date                             : UTC 2017-07-07 20:13:07
Writing application                      : mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
Writing library                          : libebml v1.3.4 + libmatroska v1.4.5

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L4@Main
Codec ID                                 : V_MPEGH/ISO/HEVC
Duration                                 : 57mn 27s
Bit rate                                 : 2 004 Kbps
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) fps
Original frame rate                      : 23.976 (23976/1000) fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.040
Stream size                              : 823 MiB (91%)
Title                                    : HEVC x265 10bit Video / 2000 kbps / 1080p / 23.976 fps / Main 10 Profile 4
Writing library                          : x265 1.9:[Linux][GCC 4.6.2][64 bit] 10bit
Encoding settings                        : wpp / ctu=64 / min-cu-size=8 / max-tu-size=32 / tu-intra-depth=1 / tu-inter-depth=1 / me=3 / subme=3 / merange=57 / rect / no-amp / max-merge=3 / temporal-mvp / no-early-skip / rdpenalty=0 / no-tskip / no-tskip-fast / strong-intra-smoothing / no-lossless / no-cu-lossless / no-constrained-intra / no-fast-intra / no-open-gop / no-temporal-layers / interlace=0 / keyint=250 / min-keyint=23 / scenecut=40 / rc-lookahead=25 / lookahead-slices=4 / bframes=4 / bframe-bias=0 / b-adapt=2 / ref=3 / limit-refs=3 / limit-modes / weightp / no-weightb / aq-mode=1 / qg-size=32 / aq-strength=1.00 / cbqpoffs=0 / crqpoffs=0 / rd=4 / psy-rd=2.00 / rdoq-level=2 / psy-rdoq=1.00 / signhide / deblock / sao / no-sao-non-deblock / b-pyramid / cutree / no-intra-refresh / rc=2 / pass / bitrate=2000 / qcomp=0.60 / qpmin=0 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ipratio=1.40 / pbratio=1.30
Default                                  : Yes
Forced                                   : No

Audio
ID                                       : 2
Format                                   : AAC LC SBR
Format/Info                              : Advanced Audio Codec Low Complexity with Spectral Band Replication
Commercial name                          : HE-AAC
Format settings                          : Explicit
Codec ID                                 : A_AAC-2
Duration                                 : 57mn 27s
Bit rate                                 : 192 Kbps
Channel(s)                               : 6 channels
Channel layout                           : C L R Ls Rs LFE
Sampling rate                            : 48.0 KHz
Frame rate                               : 23.438 fps (2048 SPF)
Compression mode                         : Lossy
Delay relative to video                  : 40ms
Stream size                              : 78.9 MiB (9%)
Title                                    : HE-AAC / 5.1 / 48 kHz / 192 kbps
Language                                 : English
Default                                  : No
Forced                                   : No

Mediainfo for mp4 file that fails to resume:

General
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/isom)
File size                                : 908 MiB
Duration                                 : 57mn 39s
Overall bit rate mode                    : Variable
Overall bit rate                         : 2 201 Kbps
Encoded date                             : UTC 2019-06-24 01:15:47
Tagged date                              : UTC 2019-06-24 01:16:34

Video #1
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L4@Main
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 57mn 39s
Bit rate                                 : 2 004 Kbps
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 23.976 (24000/1001) fps
Minimum frame rate                       : 23.810 fps
Maximum frame rate                       : 24.390 fps
Original frame rate                      : 23.976 (23976/1000) fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.040
Stream size                              : 826 MiB (91%)
Writing library                          : x265 1.9:[Linux][GCC 4.6.2][64 bit] 10bit
Encoding settings                        : wpp / ctu=64 / min-cu-size=8 / max-tu-size=32 / tu-intra-depth=1 / tu-inter-depth=1 / me=3 / subme=3 / merange=57 / rect / no-amp / max-merge=3 / temporal-mvp / no-early-skip / rdpenalty=0 / no-tskip / no-tskip-fast / strong-intra-smoothing / no-lossless / no-cu-lossless / no-constrained-intra / no-fast-intra / no-open-gop / no-temporal-layers / interlace=0 / keyint=250 / min-keyint=23 / scenecut=40 / rc-lookahead=25 / lookahead-slices=4 / bframes=4 / bframe-bias=0 / b-adapt=2 / ref=3 / limit-refs=3 / limit-modes / weightp / no-weightb / aq-mode=1 / qg-size=32 / aq-strength=1.00 / cbqpoffs=0 / crqpoffs=0 / rd=4 / psy-rd=2.00 / rdoq-level=2 / psy-rdoq=1.00 / signhide / deblock / sao / no-sao-non-deblock / b-pyramid / cutree / no-intra-refresh / rc=2 / pass / bitrate=2000 / qcomp=0.60 / qpmin=0 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ipratio=1.40 / pbratio=1.30
Encoded date                             : UTC 2019-06-24 01:15:47
Tagged date                              : UTC 2019-06-24 01:16:31
Menus                                    : 6,7
Codec configuration box                  : hvcC

Video #2
ID                                       : 7
Format                                   : JPEG
Codec ID                                 : jpeg
Duration                                 : 57mn 39s
Bit rate mode                            : Variable
Bit rate                                 : 495 bps
Width                                    : 640 pixels
Height                                   : 360 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 0.002 fps
Minimum frame rate                       : 0.001 fps
Maximum frame rate                       : 0.013 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 1.074
Stream size                              : 242 KiB (0%)
Default                                  : No
Encoded date                             : UTC 2019-06-24 01:16:34
Tagged date                              : UTC 2019-06-24 01:16:34
Menu For                                 : 1
ColorSpace_ICC                           : RGB

Audio
ID                                       : 2
Format                                   : AAC LC SBR
Format/Info                              : Advanced Audio Codec Low Complexity with Spectral Band Replication
Commercial name                          : HE-AAC
Format settings                          : Explicit
Codec ID                                 : mp4a-40-2
Duration                                 : 57mn 39s
Source duration                          : 57mn 39s
Bit rate mode                            : Variable
Nominal bit rate                         : 192 Kbps
Maximum bit rate                         : 212 Kbps
Channel(s)                               : 6 channels
Channel layout                           : C L R Ls Rs LFE
Sampling rate                            : 48.0 KHz
Frame rate                               : 23.438 fps (2048 SPF)
Compression mode                         : Lossy
Source stream size                       : 79.2 MiB (9%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 1
Encoded date                             : UTC 2019-06-24 01:15:47
Tagged date                              : UTC 2019-06-24 01:16:31
tagc                                     : public.main-program-content

* I have skipped the subtitle/chapter tracks from the files above

Guess I’m the only one using Plex this way…?

Is there some way to file a bug? This behaviour Is definitely not normal.

I’m curious where you’re at with this one. Any news on your 100% cpu usage
or on hacking Safari.xml for the newer PMS and web apps?

Is the mkv with high cpu usage running like that because HEVC Profile 2 is not supported,
i.e. Main10? I’ve seen that a few times in various logs.

I noticed the MP4 you linked also has a track of JPEGs as a video? That’s neat.
Can you remux that video without that track and test again? Just curious if we can
reduce the variables.

FWIW, I came here searching for the exact media types supported by the web app.
I’m having no luck searching for that atm.

Hello there,

I just downloaded Server version 1.17.0.1709 from the beta channel and the high CPU usage seems to be fixed! This is great. I tested with the original MKV file. The video in this file is HEVC x265 10bit Video / 2000 kbps / 1080p / 23.976 fps / Main 10 Profile 4 as reported by Plex. I have not edited the Safari.xml any further than what I posted above. It plays in Direct Stream mode as it expected with MKV in Safari.

Not sure if this has to do with subtitles I have always on (there is a related fix in the release notes) but when using Picture in Picture with Safari (which was my original target) now subtitles stop appearing when the tab that plays back the video is not the active tab (like if the tab is not in focus, the web app stops rendering subtitles), which kinda defeats the purpose – this is not HEVC specific though, so I might start a new topic on this if needed.

Regarding your search, the media types supported by the web app are dictated by what a browser supports (and probably the OS). For example Firefox and Chrome can playback webm video, but Safari cannot. I think the XML files that are supposed to indicate what a browser/device support are not up to date, or are made taking in mind the lowest specs scenario (e…g. support old Safari versions or older Macs with no HEVC playback) - this was a case with HEVC on iOS as well, not sure if they fixed that.

2 Likes

Hey that is great. Thanks for the followup.
Another win for the devs. :100:

Looking forward to hacking the browser xmls to explore what’s possible.
Really neat post, especially the PiP.

1 Like

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