Direct Play Issues, Direct Stream confusion

Posted on reddit, thought I’d post here too.

I’m having issues with Direct Play on my TCL Roku TV. The file starts to play and after 5-20s it just stops. No error message, nothing.

I’ve done some searching and I found disabling direct play and forcing direct stream fixes the issue for some files, but for others it doesn’t seem to matter. Direct stream seems to transcode random streams randomly (detailed below). Transcoding makes anything work.

Here are a few example files:

God of High School - Direct play works until 11 seconds, direct stream transcodes hevc to h264, and direct plays audio. Subtitles don’t seem to matter.

https://pastebin.com/btT0F3i6 -- <MediaContainer size="1" allowSync="1" identifier="com.plexapp.plugins.library" librarySectionID="2" librarySectionTitle="Anime" librarySectionUUID="cce641b2-ea00-4677-8976-e36f126b4cd1" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1593799535">
<Video ratingKey="68081" key="/library/metadata/68081" skipParent="1" parentRatingKey="67793" grandparentRatingKey="67792" guid="com.plexapp.agents.thetvdb://378556/1/2?lang=en" parentGuid="com.plexapp.agents.thetvdb://378556/1?lang=en" grandparentGuid="com.plexapp.agents.thetvdb://378556?lang=en" type="episode" title="Episode 2" grandparentKey="/library/metadata/67792" parentKey="/library/metadata/67793" librarySectionTitle="Anime" librarySectionID="2" librarySectionKey="/library/sections/2" grandparentTitle="The God of High School" parentTitle="Season 1" contentRating="TV-14" summary="" index="2" parentIndex="1" year="2020" thumb="/library/metadata/68081/thumb/1594735777" art="/library/metadata/67792/art/1594735777" parentThumb="/library/metadata/67793/thumb/1594735777" grandparentThumb="/library/metadata/67792/thumb/1594735777" grandparentArt="/library/metadata/67792/art/1594735777" duration="1418112" originallyAvailableAt="2020-07-13" addedAt="1594735753" updatedAt="1594735777">
<Media id="111917" duration="1418112" bitrate="2135" width="1920" height="1080" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="hevc" videoResolution="1080" container="mkv" videoFrameRate="24p" audioProfile="lc" videoProfile="main">
<Part accessible="1" exists="1" id="170970" key="/library/parts/170970/1594735762/file.mkv" duration="1418112" file="/data/Anime/The God of High School - 378556/Season 1/The God of High School - S01E02 - Episode 2 [WEBRip-1080p h265 AAC[JA] [EN]].mkv" size="378502311" audioProfile="lc" container="mkv" videoProfile="main">
<Stream id="506775" streamType="1" default="1" codec="hevc" index="2" bitrate="2135" bitDepth="8" chromaSubsampling="4:2:0" codedHeight="1088" codedWidth="1920" colorRange="tv" frameRate="23.976" height="1080" level="120" profile="main" refFrames="1" width="1920" displayTitle="1080p (HEVC Main)" extendedDisplayTitle="1080p (HEVC Main)"/>
<Stream id="506773" streamType="2" selected="1" default="1" codec="aac" index="0" channels="2" language="日本語" languageCode="jpn" audioChannelLayout="stereo" profile="lc" samplingRate="44100" displayTitle="日本語 (AAC Stereo)" extendedDisplayTitle="日本語 (AAC Stereo)"/>
<Stream id="506774" streamType="3" default="1" codec="ass" index="1" language="English" languageCode="eng" displayTitle="English (ASS)" extendedDisplayTitle="English (ASS)"/>
<Stream id="506776" streamType="3" selected="1" default="1" codec="srt" index="3" language="English" languageCode="eng" title="English" displayTitle="English (SRT)" extendedDisplayTitle="English (SRT)"/>
</Part>
</Media>
<Extras size="0"></Extras>
<Related></Related>
</Video>
</MediaContainer>

Nisekoi - Direct play works until 7 seconds, Direct stream transcodes audio from OPUS to AAC, direct plays hevc. Subtitles don’t seem to matter.

https://pastebin.com/VNgaJTms -- <MediaContainer size="1" allowSync="1" identifier="com.plexapp.plugins.library" librarySectionID="2" librarySectionTitle="Anime" librarySectionUUID="cce641b2-ea00-4677-8976-e36f126b4cd1" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1593799535">
<Video ratingKey="42938" key="/library/metadata/42938" parentRatingKey="42936" grandparentRatingKey="42935" guid="com.plexapp.agents.thetvdb://275670/1/22?lang=en" parentGuid="com.plexapp.agents.thetvdb://275670/1?lang=en" grandparentGuid="com.plexapp.agents.thetvdb://275670?lang=en" type="episode" title="Episode 22" grandparentKey="/library/metadata/42935" parentKey="/library/metadata/42936" librarySectionTitle="Anime" librarySectionID="2" librarySectionKey="/library/sections/2" grandparentTitle="Nisekoi" parentTitle="Season 1" contentRating="TV-14" summary="" index="22" parentIndex="1" year="2014" thumb="/library/metadata/42938/thumb/1594352325" art="/library/metadata/42935/art/1592580977" parentThumb="/library/metadata/42936/thumb/1592580975" grandparentThumb="/library/metadata/42935/thumb/1592580977" grandparentArt="/library/metadata/42935/art/1592580977" grandparentTheme="/library/metadata/42935/theme/1592580977" duration="1452801" addedAt="1592546170" updatedAt="1594352325" chapterSource="media">
<Media id="67298" duration="1452801" bitrate="1265" width="1920" height="1080" aspectRatio="1.78" audioChannels="2" audioCodec="opus" videoCodec="hevc" videoResolution="1080" container="mkv" videoFrameRate="24p" videoProfile="main 10">
<Part accessible="1" exists="1" id="112341" key="/library/parts/112341/1594352312/file.mkv" duration="1452801" file="/data/Anime/Nisekoi (2014) - 275670/Nisekoi - 22 - Fate + Showdown [AkihitoSubs - Bluray-1080p - x265 Opus[JA] [EN]].mkv" size="229753730" container="mkv" deepAnalysisVersion="4" requiredBandwidths="6475,3924,2628,2628,2628,2628,2628,2628" videoProfile="main 10">
<Stream id="357933" streamType="1" default="1" codec="hevc" index="0" bitrate="1265" bitDepth="10" chromaSubsampling="4:2:0" codedHeight="1080" codedWidth="1920" colorRange="tv" frameRate="23.976" height="1080" level="120" profile="main 10" refFrames="1" requiredBandwidths="6167,3615,2323,2323,2323,2323,2323,2323" width="1920" displayTitle="1080p (HEVC Main 10)" extendedDisplayTitle="1080p (HEVC Main 10)"/>
<Stream id="357934" streamType="2" selected="1" default="1" codec="opus" index="1" channels="2" language="日本語" languageCode="jpn" audioChannelLayout="stereo" requiredBandwidths="322,322,322,322,322,322,322,322" samplingRate="48000" title="Japanese" displayTitle="日本語 (OPUS Stereo)" extendedDisplayTitle="Japanese (日本語 OPUS Stereo)"/>
<Stream id="357935" streamType="3" selected="1" default="1" codec="ass" index="2" language="English" languageCode="eng" requiredBandwidths="1,1,1,1,1,1,1,1" displayTitle="English (ASS)" extendedDisplayTitle="English (ASS)"/>
<Stream id="473850" streamType="3" default="1" codec="srt" index="3" language="English" languageCode="eng" requiredBandwidths="1,1,1,1,1,1,1,1" title="undefined" displayTitle="English (SRT)" extendedDisplayTitle="undefined (English SRT)"/>
<Stream id="506777" key="/library/streams/506777" streamType="3" codec="srt" format="srt" hearingImpaired="0" title="subtitles-edit" transient="0" displayTitle="Unknown (SRT External)" extendedDisplayTitle="subtitles-edit (SRT External)"/>
</Part>
</Media>
<Writer id="68121" filter="writer=68121" tag="Akiyuki Shinbo, Fuyashi Tou"/>
<Chapter id="13809" filter="thumb=13809" tag="Prologue" index="1" startTimeOffset="7" endTimeOffset="33082" thumb="/library/media/67298/chapterImages/1"/>
<Chapter id="3979" filter="thumb=3979" tag="Opening" index="2" startTimeOffset="33082" endTimeOffset="124840" thumb="/library/media/67298/chapterImages/2"/>
<Chapter id="7927" filter="thumb=7927" tag="Episode" index="3" startTimeOffset="124840" endTimeOffset="1361868" thumb="/library/media/67298/chapterImages/3"/>
<Chapter id="7825" filter="thumb=7825" tag="Ending" index="4" startTimeOffset="1361868" endTimeOffset="1451832" thumb="/library/media/67298/chapterImages/4"/>
<Chapter id="25524" filter="thumb=25524" tag="Endcard" index="5" startTimeOffset="1451832" endTimeOffset="1452793"/>
<Marker type="intro" startTimeOffset="31073" endTimeOffset="124756"/>
<Extras size="0"></Extras>
<Related></Related>
</Video>
</MediaContainer>

The 100 - Direct play works fine, no issues at all. Subtitles disabled (haven’t tried enabling them)

https://pastebin.com/iVZBiQKk -- <MediaContainer size="1" allowSync="1" identifier="com.plexapp.plugins.library" librarySectionID="1" librarySectionTitle="TV Shows" librarySectionUUID="b884a4ea-279c-4af4-af2c-27bfd5b71458" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1593799535">
<Video ratingKey="60136" key="/library/metadata/60136" parentRatingKey="24175" grandparentRatingKey="17875" guid="com.plexapp.agents.thetvdb://268592/7/8?lang=en" parentGuid="com.plexapp.agents.thetvdb://268592/7?lang=en" grandparentGuid="com.plexapp.agents.thetvdb://268592?lang=en" type="episode" title="Anaconda" grandparentKey="/library/metadata/17875" parentKey="/library/metadata/24175" librarySectionTitle="TV Shows" librarySectionID="1" librarySectionKey="/library/sections/1" grandparentTitle="The 100" parentTitle="Season 7" contentRating="TV-14" summary="Clarke confronts a new adversary. A surprising connection takes us back to the past and to the nuclear apocalypse that destroyed the Earth." index="8" parentIndex="7" year="2020" thumb="/library/metadata/60136/thumb/1594276785" art="/library/metadata/17875/art/1594261660" parentThumb="/library/metadata/24175/thumb/1594261660" grandparentThumb="/library/metadata/17875/thumb/1594261660" grandparentArt="/library/metadata/17875/art/1594261660" grandparentTheme="/library/metadata/17875/theme/1594261660" duration="2544833" originallyAvailableAt="2020-07-08" addedAt="1594261602" updatedAt="1594276785">
<Media id="108597" duration="2544833" bitrate="846" width="1920" height="1080" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="hevc" videoResolution="1080" container="mkv" videoFrameRate="24p" audioProfile="lc" videoProfile="main 10">
<Part accessible="1" exists="1" id="159982" key="/library/parts/159982/1594252800/file.mkv" duration="2544833" file="/data/Television/The 100 (2014) - 268592/Season 7/The 100 - S07E08 - Anaconda [HDTV-1080p x265 AAC [EN]].mkv" size="270510511" audioProfile="lc" container="mkv" deepAnalysisVersion="4" requiredBandwidths="2508,2508,2508,2508,2508,2508,2508,2508" videoProfile="main 10">
<Stream id="467777" streamType="1" default="1" codec="hevc" index="0" bitrate="721" bitDepth="10" chromaLocation="left" chromaSubsampling="4:2:0" codedHeight="1088" codedWidth="1920" colorRange="tv" frameRate="23.976" height="1080" level="120" profile="main 10" refFrames="1" requiredBandwidths="2403,2403,2403,2403,2403,2403,2403,2403" width="1920" displayTitle="1080p (HEVC Main 10)" extendedDisplayTitle="1080p (HEVC Main 10)"/>
<Stream id="467778" streamType="2" selected="1" default="1" codec="aac" index="1" channels="2" bitrate="126" language="English" languageCode="eng" audioChannelLayout="stereo" profile="lc" requiredBandwidths="126,126,126,126,126,126,126,126" samplingRate="44100" displayTitle="English (AAC Stereo)" extendedDisplayTitle="English (AAC Stereo)"/>
<Stream id="467779" streamType="3" codec="ass" index="2" bitrate="0" language="English" languageCode="eng" requiredBandwidths="1,1,1,1,1,1,1,1" title="English SDH" displayTitle="English (ASS)" extendedDisplayTitle="English SDH (ASS)"/>
</Part>
</Media>
<Extras size="0"></Extras>
<Related></Related>
</Video>
</MediaContainer>

Further details:
Plex Version 1.19.5.3035 running in Linuxserver.io docker container
TV: Roku TV 7120X, TCL model 55R615, software version 9.3.0 - build 4182-30
See also the reddit thread with some q&a - https://www.reddit.com/r/PleX/comments/hr3m8u/direct_play_issues_direct_steam_confusion/

Please verify DEBUG logging enabled, VERBOSE disabled.
Restart PMS
Recreate the playback failure(s) (1-2 will do)
Wait 20 seconds
Download the Logs ZIP file and attach it here.

I’ll take a look.

Plex Media Server Logs_2020-07-14_22-40-35.zip (1.4 MB)

I would’ve done this hours ago but I didn’t see your message. Anyway, I did as you asked, but noticed there’s logs from June in there also? I hope you can sort out what you need. Let me know if you need anything else.

Thank youu

Edit: I read some other forum posts, here’s the client log if it’s helpful – https://pastebin.com/raw/MhPYUE9h

@ChuckPa have you had a chance to look into this at all?

Thank you for the logs but they don’t cover the same time period.

The client logs are newer (15th) and the server logs end on the 14th

This sounds like the MKV container is in bad shape. Many players can handle this, however the Roku is a bit pickier. One of the common results is the file ending early without error as the player believes the file is complete, another is not being able to seek (all during direct play). The only true fix when that happens is to remux the affected media file. A simple method is to use mkclean which will fix most container issues and remux the streams. Try running on of the affected file through mkclean and replace it with the output.

@ljunkie I don’t have a windows computer available to run mkclean. Are there any other ways to do this? I use ffmpeg to re-encode embedded subtitles from .ass to .srt, perhaps my code is doing something? Or I can clean it up with ffmpeg?

@ChuckPa It’s the same file and error, but I’ll pull together some logs from the same time period.

@ChuckPa
https://pastebin.com/vUw5d7cX - client
Plex Media Server Logs_2020-07-16_18-54-15.zip (3.2MB)

Sorry, I didn’t realize they no longer include other prebuilt binaries. If you have a mac, you can use brew to install it brew install mkclean. It can also be built from source, or maybe there is a linux binary somewhere on the internet. You can use mkvtoolnix to remux, as well as ffmpeg.

@ljunkie Unfortunately Plex server (and it’s files) are not local at the moment, so using my mac is out. I’ve having trouble compiling mkclean on my server, the instructions just say ./configure but I’m just getting errors. How do I do this with ffmpeg? Should I just ffmpeg -i file.mkv -c copy out.mkv?

Do you have mkvtoolnix , specifically mkvmerge ?

Yes I do

Fire up the gui and remux the file.
It will re multiplex it and write the container fresh.

I’m running a headless server, no gui.

ok…

I do it this way:

mkvmerge -o temp.mkv -M -S --no-global-tags --disable-track-statistics-tags "input file"

If there are no errors. and it tests ok, i rename it and use it.

ffmpeg -i input.mkv -c copy output.mkv seems to have worked just as well. Now my subtitles seem to be blank. I think that’s my fault though. But it seems this has worked, now I need to figure out why my script is messing up these files…

you forgot to copy your subtitles -c:s copy

I’ve seen it go goofy like that

In my example above -S strips subtitles… take off that option.

Plex reports the subtitles as present. They just seem to be blank. My script if interested. I think the issue is somewhere in the sed regex

you have a sed regex?

So basically the script pulls out .ass subtitles as .srt, removes all the html, and put the .srt back into the file (well into a new file with the original contents)