Precise file constraints

apple-tv

#1

Thank you everyone, I think the ATV4 implementation is wonderful. However, for me at least, it is somewhat hit and miss at present. Some of my files (all h.264 mp4s) play perfectly, and others cause the ATV to stall/hang.

Would it help if people like me post the details of files that don't play/files that do play, or is it best to allow the inevitable early upgrades to come through first?

As a matter of interest, as mentioned above, some files play and others don't but I don't think that Plex has tried to transcode a single one of them - they all (well at least the 95% that I have checked up on) direct play or fail in the attempt to direct play - it would be very helpful to know what are the precise file constraints are.


#2

Apple states the spec, for h264 it's level 4.2 main or high profile, which is 50 and 62.5mbit respectively. Check the Apple product page as Plex uses the native player.

There is a thread discussing where some BD rips stutter or pixelate if that is your issue:
https://forums.plex.tv/discussion/191972/dropped-frames-and-visual-artifacts-on-sony-warner-bros-mpeg-4-avc-blu-rays#latest


#3

No, that's not my question.

I have files which are well within those limits and yet still won't play. That's why I asked about precise constraints. For example, the Roku has a limit on the number of reference frames and is restricted to a single video stream.

I wanted to know if there are similar constraints with the ATV4.

I can easily post the mediainfo of this will/won't play files, but I was trying to 'debug' the situation myself before posting.


#4

Apple is probably your point of call, I'm mobile at the moment but imagine it's in developer documentation. Although level 4.2 h264 specifies this sort of thing, there is an article on Wikipedia stating the compliance requirements for that level.

I note as per the other thread compliant bluray rips not playing so the built in player seems to have some glitches even if the file is in spec.


#5

@Malcolm Clark said:
I can easily post the mediainfo of this will/won't play files, but I was trying to 'debug' the situation myself before posting.

I (and probably others) would find such a list interesting. It would help decide on what of my own files I need to re-encode or remux and to what.


#6

I have looked everywhere that I can think of for the precise file constraints, but cannot find - I would assume that the Plex developers must know - is it possible to share this information.

In case it is any help, I have copied in the media info of two files that direct play and two that don't. If anyone can shed any light on this, it would be appreciated. BTW, I'm using PMS 9.14.1, and I checked out the network speed at around 55Mbps.

1 This direct plays:
General
Complete name : \SERVER\Videos\TV shows\London Spy\London Spy - s01e02.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 1.35 GiB
Duration : 57mn 59s
Overall bit rate mode : Variable
Overall bit rate : 3 325 Kbps
Writing application : Lavf54.63.104

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 57mn 59s
Bit rate : 3 066 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 fps
Standard : Component
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.059
Stream size : 1.24 GiB (92%)
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 57mn 59s
Duration_LastFrame : -21ms
Bit rate mode : Variable
Bit rate : 253 Kbps
Maximum bit rate : 256 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 105 MiB (8%)
Language : English

2 This direct plays:

General
Complete name : \SERVER\Videos\F1\Formula 1\Season 2015\Formula 1 - s2015e018 - The Brazilian Grand Prix (2).mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 3.84 GiB
Duration : 58mn 4s
Overall bit rate mode : Variable
Overall bit rate : 9 463 Kbps
Writing application : Lavf54.63.104

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 58mn 4s
Bit rate mode : Variable
Bit rate : 9 204 Kbps
Maximum bit rate : 15.0 Mbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 fps
Standard : PAL
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.178
Stream size : 3.73 GiB (97%)
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 58mn 4s
Duration_LastFrame : -21ms
Bit rate mode : Variable
Bit rate : 253 Kbps
Maximum bit rate : 256 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 105 MiB (3%)
Language : English

3 This does not direct play:

General
Complete name : \SERVER\Videos\F1\Formula 1\Season 2015\Formula 1 - s2015e017 -The Brazilian Grand Prix.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 3.00 GiB
Duration : 58mn 4s
Overall bit rate mode : Variable
Overall bit rate : 7 390 Kbps
Writing application : Lavf54.63.104

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 58mn 4s
Bit rate : 7 066 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 fps
Standard : Component
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.136
Stream size : 2.87 GiB (96%)
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 58mn 4s
Duration_LastFrame : -21ms
Bit rate mode : Variable
Bit rate : 320 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 132 MiB (4%)
Language : English

4 And this does not direct play:

General
Complete name : \SERVER\Videos\TV shows\The Bridge (2011)\Season 02\The Bridge (2011) - s02e01.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 1.20 GiB
Duration : 57mn 31s
Overall bit rate mode : Variable
Overall bit rate : 2 988 Kbps
Writing application : Lavf53.31.100
Xtra : WM/MediaClassPrimaryID

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L3.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 57mn 31s
Bit rate mode : Variable
Bit rate : 2 793 Kbps
Maximum bit rate : 9 500 Kbps
Width : 720 pixels
Height : 576 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 fps
Standard : PAL
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Interlaced
Scan order : Top Field First
Bits/(Pixel*Frame) : 0.269
Stream size : 1.12 GiB (93%)
Color range : Limited

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 57mn 31s
Duration_LastFrame : -21ms
Bit rate mode : Variable
Bit rate : 192 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 77.9 MiB (6%)
Language : English


#7

The server log right after starting to play the video should say why it decided to transcode.


#8

@BigWheel said:
The server log right after starting to play the video should say why it decided to transcode.

But that's one of my points - Plex didn't try to transcode any of the files - the ones that didn't direct play basically didn't play - the only way I could get them to play at all was to reduce the bit rate setting to such a low level that a transcode was forced.


#9

gotcha sorry.

is it possible to get a sample file that we can test with. and the server log after hitting Play. https://support.plex.tv/hc/en-us/articles/201035968-Generating-Sample-Files-from-Media


#10

@BigWheel said:
gotcha sorry.

is it possible to get a sample file that we can test with. and the server log after hitting Play. https://support.plex.tv/hc/en-us/articles/201035968-Generating-Sample-Files-from-Media

Thank you - yes, I'll do that, but not until tonight (UK time)


#11

@BigWheel

Sorry for the delay in replying. But here's a link to a one minute clip. It's a relatively low resolution file. It tries to direct play, but after about one minute of 'playing' the video had only advanced by 1 second and all I got was a bit of garbled sound (there may have been a bit of video, but I didn't see that because I was running upstairs to my server to check that it was trying to direct play. When I got back to my TV, it was just the progress line at the bottom and the revolving (stalled sigh) circle.

https://www.dropbox.com/s/sjb34he73sku5yw/The%20Bridge%20%282011%29%20-%20s02e01%20-%20one%20minute%20test.mp4?dl=0

Server log is attached.

I hope this helps

Again I would thank everyone involved in this project. Obviously it's difficult (at least for me) to know if it's Plex or the ATV4 that's at fault.

It really would be helpful though if someone could publish the exact file constraints (then I would know how to encode for the future.

Best wishes
Malcolm


#12

Hi, Malcolm Clark

I am taking a look at your log and can see the Apple TV is direct playing F:\ServerFolders\Videos\TV shows\The Bridge (2011)\Season 02\The Bridge (2011) - s02e02.mp4 and there is no transcoding happening.

The logs do not go far enough back to when you started playback of that file but I can also see that your attempts to play the one minute test file were also via Direct Play

Nov 21, 2015 09:53:17:708 [6004] DEBUG - MDE: analyzing media item 24960
Nov 21, 2015 09:53:17:708 [6004] DEBUG - MDE: The Bridge (2011) - s02e01 - one minute test (2015): DirectPlay
Nov 21, 2015 09:53:17:708 [6004] DEBUG - MDE: The Bridge (2011) - s02e01 - one minute test (2015): selected media 0 / 24960

I have tested your sample file here and I have issues with both Direct Play and Direct Stream.

Would you mind sending me a private message with a download link to both Formula 1 - s2015e017 -The Brazilian Grand Prix.mp4 and The Bridge (2011) - s02e01.mp4 so I can investigate using the source files?


#13

Hi, Malcom I have taken a further look at the sample file you provided and it looks like there is some issue with the H264 stream that the native Apple TV player does not like.

Here you can see the AVFoundation (native Apple TV player) reporting an error back to the Plex App.

Nov 27 11:23:19 Apple-TV Plex[201] <Warning>: -[AVFrameSet _fetchNextFrame] FAILED to fetch frame for time 0.0 sec because Error Domain=AVFoundationErrorDomain Code=-11821 "Cannot Decode" UserInfo={NSUnderlyingError=0x141265320 {Error Domain=NSOSStatusErrorDomain Code=-12911 "(null)"}, NSLocalizedFailureReason=The media data could not be decoded. It may be damaged., NSLocalizedDescription=Cannot Decode}
Nov 27 11:23:20 Apple-TV Plex[201] <Warning>: -[AVFrameSet _fetchNextFrame] FAILED to fetch frame for time 32.0 sec because Error Domain=AVFoundationErrorDomain Code=-11821 "Cannot Decode" UserInfo={NSUnderlyingError=0x141089980 {Error Domain=NSOSStatusErrorDomain Code=-12911 "(null)"}, NSLocalizedFailureReason=The media data could not be decoded. It may be damaged., NSLocalizedDescription=Cannot Decode}

I could successfully play the sample by setting Allow Direct Play and Allow Direct Stream to off in the Apple TV settings. This resulted in PMS transcoding the file.


#14

Hi Chris
Thank you for taking the time to look at my file.

I'm currently uploading the source files to dropbox - I'll send you a PM with links when they finally get uploaded - you'll appreciate they're fairly big.

I don't think that the 'The Bridge' file is damaged. It certainly plays ok on other devices. I have quite a lot of files encoded with the same parameters. I can try watching more on my ATV 4 to see if they fail in a similar manner if that helps - but I'm reasonably confident, they will all refuse to direct play despite being relatively low bitrate mp4 files. My guess is that the problem with the ATV 4 is the 3 reference frames (but that's only a guess).

I also have a number of files encoded to the same spec as the 'Brazilian GP' file that I'm sending you. And again, they portray similar problems on the ATV4. I was watching one last night and every few minutes, it paused or stuttered or the screen went green for a few seconds. When the file was playing properly, the quality was absolutely perfect (certainly better that my Roku or RPi2). Again my guess is that the ATV4 can nearly play the file but there are times when there is a complete scene shift (I hope that describes it well enough) and this causes a spike in the bitrate that chokes Plex or the ATV4. Now my theory is that this is because the files are AVC component (per Mediainfo). I'm not an expert, but I believe this means that the file has >1 video streams and this was a constraint with the Roku (but not with the RPi). I took one of my Grand Prix files and transcoded (with Handbrake) to something that was much higher bitrate than the original (but only a single video stream) and I can direct play that ok.

I hope this helps - I really do have high hopes for this project and am prepared to do 'my bit' to help to iron out the original teething problems.
Best wishes
Malcolm


#15

Hi, Malcom

I tried the Formula 1 - s2015e017 -The Brazilian Grand Prix.mp4 file and it fails to Direct Play or Direct Stream cleanly on both the Plex for Apple TV and Plex for iOS app. Both of which use the native iOS/tvOS video player. (we just pass the video to the player to decode and play)

If I turn of Direct Play and Direct Stream in the Apple TV or iOS app the file is transcoded by the Plex Media Server and the resulting file plays just fine without garbled or green frames.

Nov 29 20:54:10 Apple-TV Plex[419] <Warning>: -[AVFrameSet _fetchNextFrame] FAILED to fetch frame for time 1870.0 sec because Error Domain=AVFoundationErrorDomain Code=-11821 "Cannot Decode" UserInfo={NSUnderlyingError=0x14fdb98f0 {Error Domain=NSOSStatusErrorDomain Code=-12911 "(null)"}, NSLocalizedFailureReason=The media data could not be decoded. It may be damaged., NSLocalizedDescription=Cannot Decode}

The Formula 1 - s2015e017 -The Brazilian Grand Prix.mp4 file also seems to be interlaced which is not the issue, but worth pointing out as high-motion sports content is not very nice to watch when it comes from an interlaced source :)

To confirm interlaced content is not the issue, the following 1080i Interlaced test file plays just fine on the Apple TV (http://solidrun.maltegrosse.de/~fritsch/1080i50_h264_mbaff.mp4)

I also tested your The Bridge (2011) - s02e01.mp4 file and It would play with a black screen for a bit then stop and buffer, then play for a bit then buffer. I also see a similar decoding error from the Apple TV native player.

Nov 29 20:58:55 Apple-TV Plex[419] <Warning>: -[AVFrameSet _fetchNextFrame] FAILED to fetch frame for time 1740.0 sec because Error Domain=AVFoundationErrorDomain Code=-11821 "Cannot Decode" UserInfo={NSUnderlyingError=0x14fc7adf0 {Error Domain=NSOSStatusErrorDomain Code=-12911 "(null)"}, NSLocalizedFailureReason=The media data could not be decoded. It may be damaged., NSLocalizedDescription=Cannot Decode}

I suggest you look at the software that is recording these files and perhaps record the output as MPEGTS and then use handbrake to convert the recordings to an MP4 file with an h264 stream that can be decoded without error in the iOS and Apple TV hardware.


#16

HI Chris
Thank you for taking the time to answer, however I have to say that I'm confused.

I've been recording OTA for 3 years or so now, and I can guarantee that all my files play on a different player (either Roku 3 or Rasplex over the last year).

Your email implies that you think my files are damaged in some way, but if they were, why do they play on other players? Is there a good way for me to test the integrity of a video stream?

Until recently I was recording using WMC to record my files but have recently moved to Next PVR (because Windows 10 does not support WMC).

The 'The Bridge' file was recorded as a WTV file but SD so it was an MPEG and I used Videoredo to transcode to an MP4. That was my standard workflow for a long period of time and I have 100 (a guess) TV programs recorded and transcoded in that manner all of which play on a different player and none of which (of those I have tested) play on the ATV. I'm willing to try more of them, but I do find it hard to believe that they are all damaged. I'm more prone to believing that there is a constraint within ATV (obviously it doesn't like my files) and this is why I am trying to find what it doesn't like about them. Hence my original request for precise file constraints.

For the GP file. this is HD - it was therefore recorded as a .ts with a h.264 video stream and I just use Videoredo to cut off the dross at the beginning and end; convert the sound to AAC and repackage as a mp4 (so no transcoding of the video stream). Again I have to say that all my files play on a different player (for this file it will direct play on my Rasplex - it certainly will not play on my Roku due to the >1 video stream. I don't know if this universal, but here in the UK, every HD recording is 'component AVC' which I take to mean >1 video stream).

I'm also interested as to why you say that my GP file is interlaced - I've just checked with Mediainfo and it says it's progressive.

As I've said before, I'm willing to do anything (within reason) to help solve this. There is obviously something that ATV doesn't like about my files (and seemingly about al lot of other people's files). And the 'problem' with my files not playing could be down to ATV or to Plex - it's impossible for me to say.

However the 'selling point' of Plex is that it is supposed to know what your device can play and if the particular media file doesn't fit within those constraints, then Plex is supposed to transcode. Which quite patently it's not doing in my case.

I really don't want this to sound like I'm moaning. I know it's early days, and I'm sure things will get ironed out as the ATV and Plex app mature. But I see so much potential here and I would like to do what I can to resolve the various initial problems,

Best wishes
Malcolm


#17

Hi there
Chris's comment about interlaced has set me thinking.....

I've looked at the two files that I sent, and although I don't think the Grand Prix is interlaced, the The Bridge file certainly was.

So, I've just created 8 copies of the The Bridge file, all transcoded using different settings, to see which single parameter I have to change to make the file Direct Play (and by Direct Play I mean a file that Plex reports as being direct played and which actually shows up as a video, rather than a revolving circle on a black background on my TV).

I did the 8 copies, so that I could change things one step at a time and I am reasonably certain that it is the integrated/progressive that makes the difference.

ie interlaced, tries to direct play, but show the revolving circle on my TV screen; progressive seems to work perfectly.

I'm fully prepared to do some more testing if it is going to help, and I do feel that what I have done:

  1. Shows that there was nothing inherently wrong with my video stream.
  2. Points to interlaced files as a potential problem.

I look forward to any comments.

Best wishes
Malcolm


#18

Can someone please let me know if any notice has been taken of my above post. If there is an ATV problem with interlaced files, then surely Plex needs to be able to identify and transcode them.

Lots of people are having various problems with mp4 files and as yet there is no real consensus as to what direct plays and what prevents a file from direct playing - that's why I began this thread.


#19

Hi, Malcom Clark sorry for the large delay in responding. I have been busy with some other things and away on holiday.

I have taken some of your questions and tried to answer them below;

Your email implies that you think my files are damaged in some way, but if they were, why do they play on other players? Is there a good way for me to test the integrity of a video stream?

The native video player (and native Apple H.264 hardware decoder) in the Apple TV appears to be "pickier" than other players such as "Plex Media Player" which uses mpv as its playback engine. This would explain why your files play fine on some devices but have issues on Apple devices.

I'm also interested as to why you say that my GP file is interlaced - I've just checked with Mediainfo and it says it's progressive.

I played the video in VLC Media Player and in MPV, and while the mediaInfo may report that it is "progressive" the video certainly looks "interlaced" in the fact that it looks clearer as soon as I enable the de-interlace filter in VLC/MPV.

However the 'selling point' of Plex is that it is supposed to know what your device can play and if the particular media file doesn't fit within those constraints, then Plex is supposed to transcode. Which quite patently it's not doing in my case.

This is true to a point. Plex Media Player, along with capabilities reported from a Plex client, works hard to determine if a file is compatible for Direct Play, and if not that, then if it can be direct streamed without conversion. In your case, your files both use mp4 video containers, have a h264 video stream, and an aac audio stream, making them for all intents, direct play compatible.

This leads us to the the likely fact that the method used to encode the h264 is not making a file that the Apple TV can decode correctly when direct played (or forced to direct stream).

One of the reasons we offer the Allow Direct Play/Allow Direct Stream options in our clients is so users can enable/disable them as required for problematic files.

I would be happy to take a look at some more recent files of yours that exhibit the issue, and see if there is something we can do to detect what it is that causes the files to play incorrectly, and then have PMS transcode them as needed.


#20

Hi Chris
Thank you for your reply.

It seems that the 'is my/isn't my file interlaced thing' is not easy to resolve one way or another. I've spent (far to much time) researching the matter and it does appear that some programmes can be transmitted using progressive at some points in the programme and interlaced at other times.

I would add the point that all my F1 files have been recorded OTA and they have not been transcoded and therefore I cannot believe they are all damaged, when my other recordings (at least the vast majority) play perfectly.

You have not commented on my >1 video stream point. I would be grateful if you could - as I say, this was an issue with the Roku, and I cannot find an answer on the ATV4 requirements on this point.

I would also appreciate it if you could address my next post down the thread, which shows quite clearly that the ATV4 can have issues with interlaced files.

One other thing I notice is that many videos play perfectly all the way through and then when I get to the 'credits' at the end, the screen turns green for a while. Originally I thought that this was odd behaviour (because the credits or the screen saying this programme was produced by ..) contain far less data than the original programme. However, I now think that there must be a 'spike' in that data rate as you go from the programme (where the scene changes slowly) to the 'titles' (this is hard to explain but I hope you understand what I mean). I've noticed similar behaviour on some documentaries, where they put up a static 'explanation screen' in the normal flow of the programme (again tricky to explain what I mean).

Does this help move forward in any way?

Best wishes
Malcolm