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....

«1

Answers

  • marceldevmarceldev Posts: 6Members ✭✭

    Here the tvOS.xml

  • kclimiekclimie Posts: 74Members, Plex Pass Plex Pass
    edited November 2017

    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: 88Members, 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: 74Members, Plex Pass Plex Pass
    edited November 2017

    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: 49Members, Plex Pass Plex Pass
    edited November 2017

    @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: 5Members ✭✭

    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: 167Members, 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 2017

    @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: 11Members, 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 2017

    @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.

  • partizan76partizan76 Posts: 167Members, Plex Pass Plex Pass
    edited December 2017

    Find solution how to optimize remux size. MacX videoconverter has profile for ATV 4k. It's allow to decrease size from 56Gb to 13Gb.

  • ipodtouchdudeipodtouchdude Posts: 1Members, Plex Pass, TunerTester Plex Pass
    edited December 2017

    I've using the command to make my film play direct but it is now playing in black and white. on my Apple TV 4K

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

  • stephenl03stephenl03 Posts: 15Members, Plex Pass Plex Pass

    @vdkplexserver If you quote and use {} around your variables, bash will be happy when expanding them...

    [root@plex ~]# XXX='/mnt/storage/plex/movies/American Assassin (2017)/American Assassin (2017) 2160p.mp4'
    [root@plex ~]# ls -l $XXX
    ls: cannot access /mnt/storage/plex/movies/American: No such file or directory
    ls: cannot access Assassin: No such file or directory
    ls: cannot access (2017)/American: No such file or directory
    ls: cannot access Assassin: No such file or directory
    ls: cannot access (2017): No such file or directory
    ls: cannot access 2160p.mp4: No such file or directory
    [root@plex ~]# ls -l "${XXX}"
    -rw-r--r--. 1 nobody nobody 19258671148 Jan  2 21:53 /mnt/storage/plex/movies/American Assassin (2017)/American Assassin (2017) 2160p.mp4
    

    This is your script with the variables enclosed in curly braces and the if statement syntax fixed for bash interpreter. I have not tested as I don't use filebot, or even have it installed. I did however validate the ffmpeg command does work perfectly.

    #!/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
    
  • GhettorabGhettorab Posts: 8Members, Plex Pass Plex Pass

    @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.

    This helped a lot! Thank you! Question, if i want to include a subtitle stream what would I have to add? From what I read the subtitles have to be in a certain format or else plex will start to transcode.

  • j3d1c4nn4j3d1c4nn4 Posts: 2Members, Plex Pass Plex Pass

    I too have been struggling with the issue of playing 4k mkv files on my Apple TV 4k. As a result of this post, I've tried iFlicks, Subler, the FFMPEG script and MacX Video Converter. I've also tried a nightly build of Handbrake, which now has an Apple TV 4k profile. They all successfully converted the files to MP4 and they all play on the Apple TV, but for some reason, the video output looks really 'weird' for want of a better word. It's as though the brightness and contrast have just gone totally haywire and blown out, making them unwatchable. The only one that this doesn't happen with is MacX Video Converter, which seems to do a great job, in reasonable time, and reduces the file size quite substantially without any noticeable dip in quality. The only downside I've found with MacX, though, is that it will only allow you to include one audio track in the conversion, which screws up any notion of including surround and stereo, or a commentary track. I'd welcome any suggestions on tweaks to get these other apps to not screw up the video.

«1
Sign In or Register to comment.