Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th October 2014, 23:18   #1  |  Link
matt.k
Registered User
 
Join Date: Oct 2014
Posts: 4
Decoding artifacts on certain devices

Hi,

we got really stuck on this one. The stream is encoded using Intel QuickSync (hardware encoder) through VideoToolbox API on 2012 Macbook Air. It decodes without issues on older (A5, A6 based) iOS devices, but there are artifacts on A7, A8 devices. Video demonstrating the artifacts can be found here.

Actual stream is accessible here (HLS), or as individual segments (1, 2, 3, 4) that can be concatenated.

The encoding API doesn't give many options (turn B, P frames on/off, set bitrate, keyframe interval level and profile) and none of the options seems to have any impact on the decoding glitches.

One of the weird things about the issue is that it doesn't always happens. For example the video plays with glitches, but if it gets rewind and played again, it decodes properly.

Could anyone shed some light into this? Is there something fishy about the stream or is the decoder doing something wrong?

I'd be most grateful for any kind of response. We're also open to consulting offers if you feel like you can help us with this (in which case please send me a PM).
matt.k is offline   Reply With Quote
Old 21st October 2014, 00:32   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Just a guess - But it might have something to do with the level @ 4.2, even though actual stream doesn't conform to those specs. Many devices have problems with anything above high@L4.1. You can try setting QS to encode L4.1 if those options are exposed, or try using a level editor on a known buggy stream to set it to L4.1 and see if it makes a difference
poisondeathray is offline   Reply With Quote
Old 21st October 2014, 01:37   #3  |  Link
matt.k
Registered User
 
Join Date: Oct 2014
Posts: 4
I tried setting the encoder to different profiles, it made no difference. I also tried to remux the file now changing the level in SPS to 4.1 and it had no impact on the glitches.

Do you have any reason to believe that the stream does not conform to High@L4.2?
matt.k is offline   Reply With Quote
Old 21st October 2014, 01:45   #4  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by matt.k View Post

Do you have any reason to believe that the stream does not conform to High@L4.2?
Maybe that was a poor way of wording it...

What I mean is there is nothing in your sample that suggests L4.2 is required (ie. in terms of bitrate , frame dimensions, framerate) . ie. it should have been something lower . For example, typical L4.2 streams are 1080p59.94

http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels
poisondeathray is offline   Reply With Quote
Old 21st October 2014, 08:15   #5  |  Link
fvisagie
Registered User
 
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
Quote:
Originally Posted by poisondeathray View Post
it should have been something lower
Agreed. Using this video's Bit rate of 5978 Kbps (the higher of Bit rate and Maximum bit rate for safety's sake), the level actually comes out at 3.1 (calculator attached for reference).

Although I'm no expert but for what it's worth, the large difference between Bit rate of 5978 Kbps and Maximum bit rate of 768 Kbps doesn't look entirely sane.

@matt.k,

I suspect you are (mostly) dealing with a decoder issue, for two reasons. Firstly the fact that the encode plays correctly on some platforms but not on others, and secondly the nature of the glitching. It looks very much similar to what I saw when testing a decoder's limits empirically and giving it videos it couldn't cope with. More specifically, this looks like a decoder unable to properly reconstruct the current frame from constituent reference frames. If you look carefully, you may find that glitching disappears on key frames, or at least doesn't occur there.

There could be various reasons frame reconstruction fails, including insufficient processing power to complete the previous or current frame and/or too few decoded picture buffers. I don't think it is the latter, though - a current decoder should not struggle with this video's 2 reference frames.

Therefore, it could be something like some platforms using software instead of hardware encoding. Perhaps the more recent hardware decoders have different/stricter conformance checking.

If I were you I'd start the investigation by comparing the platforms and looking for similarities and differences in the detail of what they play this with and how.

If all else fails (i.e. you don't find and fix the problem), try to work around it by e.g. trying lower-complexity encodes on the problem platforms. Disabling CABAC might be as good a point as any to start.

After completing the investigation with the problem video, you may also want to ensure future encodes are properly level-flagged to prevent them inadvertently and unnecessarily failing decoders' level checks.
Attached Files
File Type: zip h264levl.zip (3.2 KB, 83 views)
fvisagie is offline   Reply With Quote
Old 21st October 2014, 09:45   #6  |  Link
matt.k
Registered User
 
Join Date: Oct 2014
Posts: 4
Thanks, I'll look at the calculation when the file gets approved. I agree that this looks like a decoder problem, what I don't quite understand is why it happens with this particular encoder. The decoder can decode bluray rips with much larger bitrates (I've tested it with streams up to 30mbit/s that decoded properly).

I've tried disabling CABAC during encoding, it makes no difference. I've also tried to force the encoder to output High@L3.1 instead of L4.2, which it does, but with no impact on the decoding artifacts. I'm not sure why it outputs L4.2 by default, it is bit weird. The problem also persists with no B-frames in output stream.

Could buffering period or picture timing SEI have any impact on this? (though I tried both stripping the SEI from stream and recreating picture timing / buffering period SEI using tsmuxer without any result)

Last edited by matt.k; 21st October 2014 at 16:23. Reason: typo
matt.k is offline   Reply With Quote
Old 21st October 2014, 18:26   #7  |  Link
matt.k
Registered User
 
Join Date: Oct 2014
Posts: 4
So, 2 updates:

The level 4.2 was my fault, not decoder's. I forgot to remove some debug code that has forced the decoder to output 4.2. I've re-uploaded sample without the setting, which has proper level now (3.1).

Max keyframe interval seems to affect the glitch. When set to low number (i.e. 40), the glitch is easy to reproduce. With default value (which seems to be 120) it is much more difficult to reproduce. When set to 0 it doesn't seem to happen at all (but I need to test it some more). 0 is a bit weird, documentation states that keyframes will be output when decoder feels like doing it, but it only seems to output one IDR frame at the beginning and that's it. EDIT: Maybe this also could have something to do with buffering period/picture timing SEI that are output before IDR? EDIT2: Stripping SEI makes no difference.

Last edited by matt.k; 21st October 2014 at 18:54. Reason: added SEI mention
matt.k is offline   Reply With Quote
Old 23rd October 2014, 23:35   #8  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
My guess is that the IDR frames are just too large to be real-time decoded. VBV settings will fix that, if they're available; intra-refresh definitely can, but that's only available in x264. Are you using OBS? Unfortunately, that has no way to adjust I-frame size, it's not something they've implemented for QS yet.
foxyshadis is offline   Reply With Quote
Reply

Tags
artifacts, decoder, h264

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 16:27.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.