If you have not already, we suggest setting your Plex username to something else rather than email which is displayed on your posts in forum. You can change the username at https://app.plex.tv/desktop#!/account
Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

BUG: Syncing 4K content from iOS client results in transcoding, while syncing from Plex Web works

kclimiekclimie Posts: 69Members, Plex Pass Plex Pass
edited November 11 in iOS

Like many users, I have been experimenting with HEVC and 4K files with the latest versions of Plex, PMS, and Apple iOS.

The Plex iOS client can Direct Play 4K content if it is properly encoded. Those files, if synced from within the iOS client, result in PMS transcoding the file to 1080p. However, if sync for the exact same file to the exact same client is initiated from within Plex Web, it will sync the 4K file without transcoding.

I am reporting this as a bug because the expected behavior is that the 4K file, which is Direct Play capable, should be synced without transcoding regardless of where the sync is initiated from.

Here is how to reproduce:

PMS Version 1.9.7.4441, running on Ubuntu 16.04.3 LTS. All current patches applied.
Plex iOS client Version 4.2 Build 12070 running on an 2016 iPad Pro (9.7-inch) - Model A1674
iOS version 11.1.1 (15B150)

1) The iOS.xml profile that is included with PMS still hasn't been updated to allow HEVC and/or 4K content. Customize /usr/lib/plexmediaserver/Resources/Profiles/iOS.xml profile. Reboot server after adding.

<?xml version="1.0" encoding="utf-8"?>
<Client name="iOS">
  <!-- Customized version of the iOS.xml file to allow for HEVC and 4K content -->
  <Settings>
    <Setting name="DirectPlayStreamSelection" value="true" />
    <Setting name="StreamUnselectedIncompatibleAudioStreams" value="true" />
  </Settings>
  <TranscodeTargets>
    <VideoProfile container="mp4" codec="h264" audioCodec="aac" subtitleCodec="mov_text" context="static" />
    <VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac,mp3" context="streaming">
      <Setting name="HlsExtraMultiChannelAudioStream" value="ac3" />
    </VideoProfile>
    <MusicProfile container="mp3" codec="mp3" />
    <PhotoProfile container="jpeg" />
    <SubtitleProfile protocol="hls" container="webvtt" subtitleCodec="webvtt"/>
  </TranscodeTargets>
  <DirectPlayProfiles>
    <VideoProfile container="mp4,m4v" codec="hevc,h265,h264,mpeg4" audioCodec="aac,he-aac,ac3,eac3,flac" subtitleCodec="mov_text,tx3g,ttxt,text" />
    <!-- Since tvOS may have issues direct playing mov/*/eac3 it has its own profile  -->
    <VideoProfile container="mov" codec="hevc,h265,h264,mpeg4" audioCodec="aac,he-aac,ac3,flac" subtitleCodec="mov_text,tx3g,ttxt,text" />
    <!-- Allow Direct Play of HLS content  -->
    <VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac,he-aac,ac3,eac3,flac" />
    <MusicProfile container="mp3" codec="mp3" />
    <MusicProfile container="mp4" codec="aac,he-aac,ac3,eac3,flac" />
    <PhotoProfile container="jpeg" />
  </DirectPlayProfiles>
  <CodecProfiles>
    <VideoCodec name="*">
      <Limitations>
        <UpperBound name="video.width" value="3840" />
        <UpperBound name="video.height" value="2160" />
       <UpperBound name="video.bitDepth" value="10" />
      </Limitations>
    </VideoCodec>
    <VideoAudioCodec name="*">
      <Limitations>
        <UpperBound name="audio.channels" value="8" />
      </Limitations>
    </VideoAudioCodec>
  </CodecProfiles>
</Client>

2) Download http://demo-uhd3d.com/files/uhd4k/Philips_UHD_supershopdemo_1.mp4

3) The file is not web optimized, so run it through ffmpeg to make it so.

ffmpeg -i /temp/Philips_UHD_supershopdemo_1.mp4 -map 0 -c copy -movflags +faststart -f mp4 /temp/Philips_UHD_supershopdemo_1.m4v

4) Import the new file to Plex library and Scan Library Files

5) Verify Plex sees the Media info correct. XML should shows Media info as:

  <Media videoResolution="4k" id="88021" duration="83904" bitrate="38451" width="3840" height="2160" aspectRatio="1.78" audioChannels="6" audioCodec="aac" videoCodec="hevc" container="mp4" videoFrameRate="24p" optimizedForStreaming="1" audioProfile="lc" has64bitOffsets="0" videoProfile="main 10">
   <Part accessible="1" exists="1" id="101855" key="/library/parts/101855/1510408595/file.m4v" duration="83904" file="/path/to/Media/Philips_UHD_supershopdemo_1.m4v" size="403272553" audioProfile="lc" container="mp4" has64bitOffsets="0" optimizedForStreaming="1" videoProfile="main 10">
    <Stream id="294122" streamType="1" default="1" codec="hevc" index="0" bitrate="38014" language="English" languageCode="eng" bitDepth="10" chromaSubsampling="4:2:0" colorRange="tv" frameRate="24.000" height="2160" level="153" profile="main 10" refFrames="1" streamIdentifier="1" width="3840"/>
    <Stream id="294123" streamType="2" selected="1" default="1" codec="aac" index="1" channels="6" bitrate="437" language="English" languageCode="eng" audioChannelLayout="5.1" profile="lc" samplingRate="48000" streamIdentifier="2"/>
   </Part>
  </Media>

6) Verify file can Direct Play on iOS device. It does.

7) From within iOS App, Sync file, choosing Original Quality under Advanced. PMS starts Transcoding file. Log shows:

 DEBUG - MDE: analyzing media item xxxxx
 DEBUG - Philips Uhd Sample - video.width limitation applies: 3840 > 1920
 DEBUG - MDE: Philips Uhd Sample: no remuxable profile found, so video stream will be transcoded
 DEBUG - Scaled up video bitrate to 171063Kbps based on 4.500000x fudge factor.
 DEBUG - Scaled maximum bitrate for resolution reduction to 42765Kbps.
 DEBUG - MDE: Philips Uhd Sample: selected media 0 / xxxxx

8) Cancel sync. In the Plex Web, navigate to the file. Click the Sync icon, select the iOS device used and then select Original quality.

9) On the iOS device, initiate sync. The file immediately downloads, and plays back normally.

Sign In or Register to comment.