Why do some H.264 files need transcoding for XBOXone, others don't?

Lately while trying to play some H.264 encoded movies they have started pausing during playback. Checking the server I could see that they were being transcoded. I thought this was odd as I thought the XBOXone handled H.264 playback. Some further investigation showed that some H.264 files were being transcoded, whereas others weren’t. I thought it might be bitrate related, however the ones that weren’t being transcoded had a higher bitrate in some cases.

I went looking at the XML’s for the differing files and I noticed differences in the video stream description section.

This one transcodes when it plays in an XBOXone:

<Stream id="41371" streamType="1" codec="h264" index="0" bitrate="25073" language="English" languageCode="eng" bitDepth="8" cabac="1" chromaSubsampling="4:2:0" codecID="V_MPEG4/ISO/AVC" duration="7142392" frameRate="23.976" frameRateMode="cfr" hasScalingMatrix="1" height="1080" level="41" pixelFormat="yuv420p" profile="high" refFrames="2" requiredBandwidths="23894,23769,23554,23219,22904,22589,21964,21964" scanType="progressive" width="1920" />

This one doesn’t:

<Stream id="113596" streamType="1" codec="h264" index="0" bitrate="27299" language="English" languageCode="eng" bitDepth="8" cabac="1" chromaSubsampling="4:2:0" codecID="V_MPEG4/ISO/AVC" colorRange="tv" colorSpace="bt709" duration="7271271" frameRate="23.976" frameRateMode="cfr" hasScalingMatrix="0" height="1080" level="41" pixelFormat="yuv420p" profile="high" refFrames="4" scanType="progressive" width="1920" />

Both were produced by makeMKV. Does this header information come from the original disc?

What do the different flags mean?

Any help would be appreciated, thanks. (Yes I know if I had a faster server to transcode quicker I wouldn’t need to do this, however I am interested to know)

Some further information for those that are reading this thread (hopefully a code guy)

This movie wants to transcode when it plays:-

Whereas this one plays direct-

Both are .MKV, both are AVC (H.264) albeit with different header information. So is that what trips the server up??

I would have thought that both would direct stream as the XBOXOne doesn’t do .MKV’s.

Thanks

The best thing you can provide would be the Plex Media Server.log when you try and playback the file that is transcoding. The server will say exactly why it is transcoding right before the transcoder starts up.

It very well could be something unrelated to the video itself, something such as subtitles which currently require a transcode. I am double checking, but at this time there isn’t anything I am aware of with H264 that would impose a direct play limitation by itself.

Subtitles and certain audio formats can cause transcoding. Another thing is if you’ve defaulted (or last used) a custom quality/bitrate setting. You didn’t include audio or subtitle info so I’m not sure if one of those is causing the problem or not. It looks like there isn’t any forced subtitles so it’s probably not that.

If the quality setting you currently have selected is the native bitrate of one video but different than the others native bitrate, plex will transcode the video to match the bitrate you have selected. That may be why its doing it sometimes and not others.
I would check the options while the video is playing and see what quality is selected when you play each video. The top option should be native. See if it still transcodes after selecting that.

Those are my guesses, but the logs are the only way to know for sure.

Your best option is to download a free (and amazing) encoding application called Adapter and use the Xbox preset on your files.

You can leave the video and audio settings as “same as source” and essentially all it will change is the bit rate on the files. It’ll actually optimize your files for pretty much any device since Blu-Ray bit rates are typically quite high.

You can batch process an entire folder as well so that you don’t have to sit and wait around while your movie library encodes.

So I have captured the section of the log where it decides to transcode:-

Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - MDE: analyzing media item 19750 Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - MDE: Insurgent (2015): Direct Play is disabled Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - MDE: Insurgent (2015): media must be transcoded in order to use the hls protocol Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - MDE: Insurgent (2015): no direct play video profile exists for http/mkv/h264/truehd Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - Insurgent - audio.channels limitation applies: 8 > 6 Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - Insurgent - video.hasScalingMatrix limitation applies: 1 == 1 Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - Insurgent - video.hasScalingMatrix limitation applies: 1 == 1 Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - Insurgent - video.hasScalingMatrix limitation applies: 1 == 1 Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - MDE: Insurgent (2015): no remuxable profile found, so video stream will be transcoded Aug 10, 2016 18:27:49.630 [0x7f80b4bfe700] DEBUG - Insurgent - video.hasScalingMatrix limitation applies: 1 == 1 Aug 10, 2016 18:27:49.630 [0x7f80b4bfe700] DEBUG - MDE: computed resolution bounding box of 1920x1080. Aug 10, 2016 18:27:49.630 [0x7f80b4bfe700] DEBUG - Scaled up video bitrate to 37609Kbps based on 1.500000x fudge factor. Aug 10, 2016 18:27:49.638 [0x7f80c2b3e700] INFO - [Plex for Xbox One] [MDE] Starting analysis of 1080 (mkv, h264, truehd, 41, high) Aug 10, 2016 18:27:49.647 [0x7f80b4bfe700] DEBUG - Insurgent - audio.channels limitation applies: 8 > 6 Aug 10, 2016 18:27:49.647 [0x7f80b4bfe700] DEBUG - MDE: Insurgent (2015): selected media 0 / 19750 Aug 10, 2016 18:27:49.648 [0x7f80b4bfe700] DEBUG - Found session GUID of 2q0z7aqlb3rp in session start. Aug 10, 2016 18:27:49.648 [0x7f80b4bfe700] DEBUG - Using session GUID 2q0z7aqlb3rp for new transcode session.

So what is the ‘hls’ protocol?

Edit: Apparently it stands for HTTP live streaming. So how does an .MKV file all of sudden become an Apple streaming protocol…So not sure…

Full log attached.

@K9Damien said:
Your best option is to download a free (and amazing) encoding application called Adapter and use the Xbox preset on your files.

You can leave the video and audio settings as “same as source” and essentially all it will change is the bit rate on the files. It’ll actually optimize your files for pretty much any device since Blu-Ray bit rates are typically quite high.

You can batch process an entire folder as well so that you don’t have to sit and wait around while your movie library encodes.

Thanks for the recommendation however Adapter doesn’t seem to have an XBOXOne profile. I will stick with Handbrake for the moment.

@Stephen3001 said:
Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - MDE: Insurgent (2015): no direct play video profile exists for http/mkv/h264/truehd

Aug 10, 2016 18:27:49.629 [0x7f80b4bfe700] DEBUG - Insurgent - video.hasScalingMatrix limitation applies: 1 == 1

The initial transcode is being caused by both the audio codec (TrueHD) and the number of channels (8). Typically this would result in just in the audio being transcoded, the video being copied, and everything packaged for HLS streaming to the device. However, because the video has a scaling matrix the transcoded will not copy the video stream and is forced to transcode it. This is where your issue is that is causing the video to transcode as well as the video.

So what is the ‘hls’ protocol?

Edit: Apparently it stands for HTTP live streaming. So how does an .MKV file all of sudden become an Apple streaming protocol…So not sure…

Plex prefers HLS streaming for transcoded/direct streamed files. So if the file needs to be transcoded or remuxed it will typically be done via HLS streaming.

Thanks @jmckee,

I can understand the audio transcoding. Apart from the 8 to 6 channels, it is also DTS which is a problem for the XBOXOne.

However this begs the next question, what is the video scaling matrix?

Whilst I don’t quite understand how to read the logs and to find the sections relevant to the file I have just watched. I am pretty confident this is the same issue that has been plaguing me for the last few weeks.

DTS audio always transcodes for me which is fine as my NAS can generally handle that. Bud add in the video transcoding as well and it’s useless.

The same files have always played fine for me with just the audio transcoding.

Assuming it is the same issue stated above, why has it just become an issue in the last few weeks?

And is this something I could fix by changing settings on the server or app? Or does this require a fix?

@mal68 This problem of mine relates to the actual file itself and the structure of the video in the file. Your problem might b something different, could be the same.

The best way to tap an error in the log is to stop all activity of Plex for a moment, then try to play the file in question. Find the logs on your NAS, found the most recently written one and just search for the title of the file you just tried to play.

@mal68 said:
Assuming it is the same issue stated above, why has it just become an issue in the last few weeks?
If it’s the same issue as above, it hasn’t just started. The transcoder has forced transcode for Anamorphic and Scaling Matrix for as long as I can remember. The first time I ran into this issue was when I was using the FireTV when it first came out and the transcoder was changing all my anamorphic DVD’s from 16:9 to 4:3.

If you can post your log file though, we can tell you for sure what exactly is triggering the video transcode.

@Stephen3001 said:
However this begs the next question, what is the video scaling matrix?
Unfortunately, I have no definite answer on that.

The only thing in simpler terms I can find is:
The custom quantization matrix enables a user who is encoding a video to tweak the encoder's standard settings to better fit the video material.

Which to me would mean that because video encoding has custom settings it needs the extra stuff to decode the stream properly. However, I have no idea why this stream could not be copied over.

Yes, this is what I found as well. Something about changing the DCT matrix. Anyway as suspected it was the video being a slightly different flavour of H.264.

Thats the good thing about standards, there’s so many of them.

@Stephen3001 hey just wanted to let you know that I saw some discussion on reddit that others who have experienced similar issues have “resolved” it by winding the server back to pre version 1.0.

I haven’t been able to test it myself yet as I have had a hard drive fail in my NAS, but apparently 0.9.12.19 works well

Thanks @mal68.

Don’t really want to wind back. I’ll just keep moving forward.

I moved to Plex a few months ago as the RoksBox app on my Roku 3 (model 4230R) appears to be no longer maintained. I ran across Plex and decided to give it a whirl and installed it on my local FreeNAS box as a plugin and added the Plex channel to my Roku. I am having an issue with Plex buffering content every few seconds.

I am intimately aware the of root causes of buffering after having worked six and a half years at RealNetworks supporting their Helix Server which could deliver content via RTSP, RTMP, HLS, and MPEG-DASH. While there I became their onsite encoding expert and have since created a 1,500 line bash shell script that drives FFmpeg to convert my content. I am now back in the streaming media industry after our group was laid off back in November 2014.

My content, which is H.264 video with stereo AAC audio in an MP4 container, is compliant for repacketization to all of the protocols previously mentioned. All of my keyframes are aligned with either a two or five second GOP for segmented content. I blog about encoding here. An example line from my bash shell script that I run under Cygwin on Windows is as follows:

ffmpeg.exe -threads 1 -hwaccel dxva2 $startPosition $endPosition -fpsprobesize $gop -i $inputfile $scan -pix_fmt $colorspace -vsync 1 -sn -vcodec libx264 -map $vtrack -r $fps -vf "crop=$w1:$h1:$x1:$y1,scale=$fixedwidth:$fixedheight:$fixrotation" -threads 0 -b:v:$vtrack $averagevideobitrate -bufsize $buffer -maxrate $maximumvideobitrate -minrate $minimumvideobitrate -strict experimental -acodec aac -map $audio -b:a:$audio $audiobitrate -ac 2 -ar $audiofrequency -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -pass 1 -preset $newpreset -profile:v $defaultprofile -g $gop $gohigher $newtune -x264opts no-scenecut -map_metadata -1 -f mp4 -y $outputfile

Every variable in that command line is either prepopulated on the command line or calculated in my script and then inserted for optimal bitrate as shown here. The line above might end up looking something like this:

ffmpeg.exe -threads 1 -hwaccel dxva2 -fpsprobesize 48 -i input.mp4  -pix_fmt yuv420p -vsync 1 -sn -vcodec libx264 -map 0:0 -r 23.976 -vf "crop=1920:800:0:140,scale=1920:800" -threads 0 -b:v:0 2486272 -bufsize 25059328 -maxrate 24862720 -minrate 248627 -strict experimental -acodec aac -map 0:1 -b:a:1 196608 -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -pass 1 -preset medium -profile:v high -g 48 -tune film -x264opts no-scenecut -map_metadata -1 -f mp4 -y output.mp4

Today I had my first buffering issue. I updated to Version 2.7.10 (or 1.1.3.2700-6f64a8d) as reported in the Plex Interface as I thought that an update would resolve the issue. I was wrong as the issue persists. The last version that I see is 2.7.3 (or 1.0.0.2261-a17e99e) under Settings / Web and Settings / Server respectively.

My network is 1GB Ethernet with my ASUS RT-AC66U router running the DD-WRT firmware v24-sp2 (12/22/14) giga (SVN revision 25697). I have zero issues connecting to Amazon Prime or to Netflix. My internal network is clean as Bittorrent is not in use. I do not perform transcoding with my content as my content is restricted to my internal network. Were I to consider creating ABR content I can make my own, assuming that Plex can deal with that and rate switch automatically as network bandwidth changes.

My FreeNAS box is not performing any ZFS scrubs at this time. I am not disk speed constrained.

As I am new to Plex and it appears that this issue is resolved for some people who roll back to either 1.0 or 0.9.12.19. Any advice on how to roll back to a previously working version on FreeNAS-9.10.1 (d989edd)?