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!

Apple TV 4K DirectPlay HEVC

marceldevmarceldev Posts: 6Members ✭✭

Hello

Overview:

Plex Media Server: Version 1.9.6.4429
Plex App (Apple TV 4k): v.1.19 (73565)

Video File Informations:

My tvOS.xml (attachment)

Why is it not possible to Play this Video File via DirectPlay ?

Plex tries to transcode from HEVC to h.264.... Lags Lags Lags....

Answers

  • marceldevmarceldev Posts: 6Members ✭✭

    Here the tvOS.xml

  • kclimiekclimie Posts: 78Members, Plex Pass Plex Pass
    edited November 21

    First, your file is an MKV. Apple TV only supports MP4. Second, your file has TrueHD audio in it. TrueHD is not a supported format by Apple TV. Finally, the subtitles are PGS. Text only subs are supported.

    See this post - https://forums.plex.tv/discussion/comment/1561042/#Comment_1561042

    Until Plex adds support for Direct Streaming (which will convert your MKV to MP4 on the fly in the correct streaming format), you have to follow very specific guidelines to get it to Direct Play your media.

  • ersanersan Posts: 42Members, Plex Pass Plex Pass

    Was not aware that Plex didn't support direct streaming with HEVC to remux a container - is there any reason for that?

  • kclimiekclimie Posts: 78Members, Plex Pass Plex Pass
    edited November 22

    Any time media gets re-muxed (repackaged from one format to another) the Plex server has to use a live-streaming protocol to send it to the client -- after all the file does not exist in the proper format and the server has to build it on-the-fly, so it can't just send it to the client like it can with a properly formatted file. The Plex Media Server currently uses the HTTP Live Streaming (HLS) protocol to transport the file as it is built to the client.

    Apple does not support HLS for HEVC, only Fragmented MP4, so it means a major re-write for the Plex devs. They are working on it, but we must be patient. In the meantime if you want to use HEVC material with Apple devices the media has to be formatted following very strict guidelines.

  • adamska46adamska46 Posts: 29Members, Plex Pass Plex Pass
    edited November 22

    @kclimie said:
    Apple does not support HLS for HEVC, only Fragmented MP4

    Apple does support HEVC on HLS protocol. It's only the video stream which has to be fMP4 for HEVC. Before iOS11/tvOS11/ macOS10.13, a MPEG2-TS stream was previously carried via HLS for H264 videos.

    See here for HLS examples of both MPEG2-TS (H264) and fMP4 (H264 and HEVC) : https://developer.apple.com/streaming/examples/

    PMS : NVIDIA Shield TV

  • marceldevmarceldev Posts: 6Members ✭✭

    How can I transcode this Videofile with ffmpeg in the correct "DirectPlay" Format (Without loss Quality)

  • MojobabyMojobaby Posts: 2Members

    The best solution is...
    Buy this one:

    http://www.iflicksapp.com

    and after that for the 4k releases use this one (beta):

    https://rink.hockeyapp.net/apps/938b05d3c5075d5f6cf6401d287c96bf

    It works pefect for me (preset "itunes kompatibel")

  • partizan76partizan76 Posts: 118Members, Plex Pass Plex Pass

    @Mojobaby said:
    The best solution is...
    Buy this one:

    http://www.iflicksapp.com

    and after that for the 4k releases use this one (beta):

    https://rink.hockeyapp.net/apps/938b05d3c5075d5f6cf6401d287c96bf

    It works pefect for me (preset "itunes kompatibel")

    just copy of Subler, but for money...

  • vdkplexservervdkplexserver Posts: 7Validating, Plex Pass Plex Pass
    edited November 29

    @marceldev - Just use ffmpeg 3.4 (available here for ubuntu fans) to remux the hevc.mkv to a hevc.mp4 with the necessary hvc1 vtag. Quick FYI, remuxing is so much faster than transcoding, as it only changes the container instead of re-encoding everything.

    CLI command is as follows (replace $PATH/$NAME with the appropriate path and filename)

    ffmpeg -i "$PATH/$NAME.mkv" -codec copy -vtag hvc1 -map 0:0 -map 0:1 "$PATH/$NAME.mp4"

    Source - AppleTV 4k DirectPlays all my remuxed hevc files from headless linux based plex media server. I use a bash script powered by mediainfo/ffmpeg to identify and automatically remux any HEVC mkv file it comes across.

  • hanssephanssep Posts: 12Members, Plex Pass Plex Pass

    @vdkplexserver Thanks for sharing. Maybe this addresses my frustration with the state of Plex on Apple TV 4K. I'm a big Plex fan but currently moved to Infuse as the go-to media player: no need to update anything to play 4K HDR HEVC content directly...

    Do you mind sharing your HEVC detection script? Thanks.

  • vdkplexservervdkplexserver Posts: 7Validating, Plex Pass Plex Pass
    edited November 29

    @hanssep Can't take the credit on that one. I got my inspiration from this script here. One downside is the bash script works well as long as there are no spaces in the filename when I input them from the variables $PATH/$NAME. If someone can help with that... please help! I am new at scripting so feel free to recommend any changes/additions.

    ie.
    Great.Donuts.S02E05./Great.Donuts.S02E05.mkv - this works
    Great Donuts S02E05./Great Donuts S02E05.mkv - this doesn't work as I can't get bash to pass the variable of a path/filename with spaces correctly

    This script is executed by deluge on the completion of a download.

    #!/bin/sh
    
    # Input Parameters
    ARG_PATH="$3"
    ARG_NAME="$2"
    ARG_LABEL="N/A"
    CONFIG_OUTPUT="$HOME/Media" # Filebot's final destination for the renamed file
    
    # filebot used to extract any rar
    filebot -extract "$ARG_PATH/$ARG_NAME/" --output "$ARG_PATH/$ARG_NAME/"
    
    # Mediainfo needed to check if files are encoded in hevc
    test=$(mediainfo "$ARG_PATH/$ARG_NAME.mkv" --Inform="Video;%Format%")
    echo " $ARG_NAME is $(mediainfo "$ARG_PATH/$ARG_NAME/$ARG_NAME.mkv" --Inform="Video;%Format%")" >> ~/logs/scripts.log # log if file is recognized as HEVC
    
    if [ "$test" = "HEVC" ]   # If the media file is x265 (HEVC)
    
    then
    # Run ffmpeg version 3.4 to remux only files detected as HEVC to the AppleTV required hvc1 rather than unsupported hev1
    ffmpeg -i "$ARG_PATH/$ARG_NAME/$ARG_NAME.mkv" -codec copy -vtag hvc1 -map 0:0 -map 0:1 "$ARG_PATH/$ARG_NAME/$ARG_NAME.mp4"
    
    # If it is HEVC also run this Filebot AMC script (ignore moving/renaming only *.mkv and ignore extract as files are already extracted above)
    filebot -script fn:amc --output "$CONFIG_OUTPUT" --def ignore="[.](mkv)$" --def skipExtract=y --action duplicate --conflict skip -non-strict --log-file ~/amc.log --def unsorted=y music=y artwork=y excludeList=".excludes" ut_dir="$ARG_PATH" ut_kind="multi" ut_title="$ARG_NAME" ut_label="$ARG_LABEL" plex="" #enter your plex ip address and token to notify it to update
    
    else
    
    # If not is HEVC run this Filebot AMC script
    filebot -script fn:amc --output "$CONFIG_OUTPUT" --def ignore="[.](mp4)$" --def skipExtract=y --action duplicate --conflict skip -non-strict --log-file ~/logs/amc.log --def unsorted=y music=y artwork=y excludeList=".excludes" ut_dir="$ARG_PATH" ut_kind="multi" ut_title="$ARG_NAME" ut_label="$ARG_LABEL" plex=""
    fi
    
  • marceldevmarceldev Posts: 6Members ✭✭

    @vdkplexserver said:
    @marceldev - Just use ffmpeg 3.4 (available here for ubuntu fans) to remux the hevc.mkv to a hevc.mp4 with the necessary hvc1 vtag. Quick FYI, remuxing is so much faster than transcoding, as it only changes the container instead of re-encoding everything.

    CLI command is as follows (replace $PATH/$NAME with the appropriate path and filename)

    ffmpeg -i "$PATH/$NAME.mkv" -codec copy -vtag hvc1 -map 0:0 -map 0:1 "$PATH/$NAME.mp4"

    Source - AppleTV 4k DirectPlays all my remuxed hevc files from headless linux based plex media server. I use a bash script powered by mediainfo/ffmpeg to identify and automatically remux any HEVC mkv file it comes across.

    thanks a lot ;)

    Do you mind sharing your tvOS.xml with us ?

  • vdkplexservervdkplexserver Posts: 7Validating, Plex Pass Plex Pass

    I just use the standard tvOS.xml that came with the latest Plex Media Server.

    <?xml version="1.0" encoding="utf-8"?>
    <Client name="tvOS">
      <!-- Author: Plex Inc. -->
      <!-- This profile is used by A8-based tvOS devices -->
      <Settings>
        <Setting name="DirectPlayStreamSelection" value="true" />
        <Setting name="StreamUnselectedIncompatibleAudioStreams" value="true" />
      </Settings>
      <TranscodeTargets>
        <VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac,eac3,ac3,mp3" context="streaming" />
        <MusicProfile container="mp3" codec="mp3" />
        <PhotoProfile container="jpeg" />
        <SubtitleProfile protocol="hls" container="webvtt" subtitleCodec="webvtt"/>
      </TranscodeTargets>
      <DirectPlayProfiles>
        <VideoProfile container="mp4" codec="h264,mpeg4" audioCodec="aac,ac3,eac3" subtitleCodec="mov_text,tx3g,ttxt,text" />
        <!-- Since tvOS may have issues direct playing mov/*/eac3 it has its own profile  -->
        <VideoProfile container="mov" codec="h264,mpeg4" audioCodec="aac,ac3" subtitleCodec="mov_text,tx3g,ttxt,text" />
        <!-- Allow Direct Play of HLS content  -->
        <VideoProfile protocol="hls" container="mpegts" codec="h264" audioCodec="aac" />
        <MusicProfile container="mp3" codec="mp3" />
        <MusicProfile container="mp4" codec="aac" />
        <PhotoProfile container="jpeg" />
      </DirectPlayProfiles>
      <CodecProfiles>
        <VideoCodec name="h264">
          <Limitations>
            <UpperBound name="video.width" value="1920" isRequired="true" />
            <UpperBound name="video.height" value="1080" isRequired="true" />
            <UpperBound name="video.bitDepth" value="8" />
          </Limitations>
        </VideoCodec>
        <VideoAudioCodec name="aac">
          <Limitations>
            <UpperBound name="audio.channels" value="2" />
          </Limitations>
        </VideoAudioCodec>
      </CodecProfiles>
    </Client>
    
  • b2un0b2un0 Posts: 3Members, Plex Pass Plex Pass

    @marceldev

    I use a bash script powered by mediainfo/ffmpeg to identify and automatically remux any HEVC mkv file it comes across.

    can you share your script?

  • marceldevmarceldev Posts: 6Members ✭✭

    @b2un0 said:
    @marceldev

    I use a bash script powered by mediainfo/ffmpeg to identify and automatically remux any HEVC mkv file it comes across.

    can you share your script?

    The Bash Script is coded by: @vdkplexserver. He posted it already here.

Sign In or Register to comment.