Kodi Community Forum

Full Version: New take on fixing broken interlaced HW accelerated H264 playback
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I only receive audio when tuning into a live tv channel.
Don't have this problem on OS X and Windows (same build).

Please see debug logs. Interesting part starts at line #2689.

https://dl.dropboxusercontent.com/u/3691492/kodi.log

File is too large to put on any free text paste website that I know of + xbmclogs timed out.
turn off deinterlacing in the video osd and see if you get a picture then.
Mhh i doubt this will work:

07:17:48 T:190713856 NOTICE: Decode - VTDecompressionSessionDecodeFrame returned(-12911)
07:17:48 T:190713856 DEBUG: CDVDPlayerVideo - video decoder returned error

Your best bet is to either switch toa non h264 version of that channel or disable the hardware acceleration for those channels. Its a known issue for alot of livetv providers that the VTB decoder on ios doesn't decode them (most likely because of interlaced h264 content or something else going wrong in the stream encoding).
(2015-05-12, 15:16)Memphiz Wrote: [ -> ]Mhh i doubt this will work:

07:17:48 T:190713856 NOTICE: Decode - VTDecompressionSessionDecodeFrame returned(-12911)
07:17:48 T:190713856 DEBUG: CDVDPlayerVideo - video decoder returned error

Your best bet is to either switch toa non h264 version of that channel or disable the hardware acceleration for those channels. Its a known issue for alot of livetv providers that the VTB decoder on ios doesn't decode them (most likely because of interlaced h264 content or something else going wrong in the stream encoding).

OK I'll try some other channels when I'm home later on.

So the known issue on iOS is the combination of h264 with interlaced frames? Sounds horrible in Kodi PVR context.

Can someone point me in the right direction on how to disable HW acceleration on channel level?
What are the potential workarounds for this (code wise)?
Dsable vtb hw acceleration is the only known workaround. I for myself only have this issue with HD channels (SD channels are mpeg2 which is no problem). So i only use the sd channels on my ios devices. (HD channels always have an SD pendant with my cable provider).

Its not only interlaced btw (this is something we detect and fall back to software decoding). Its about wrong encodings (my hd channels are 720p with wrong / out of spec extradata).
What if we would catch the HW decode failure and still decode it non-HW accelerated?
At the point it fails there is no way to gracefully fallback to software. There are longwinded discussions about this burried in this forum already. Opening the VTB decoder works. (that is the real problem) - the errors are coming from the hardware during decoding then.

Trust me - if it was an easy task (i know it looks pretty easy from the outside) this would have been implemented already. (as this problem exists for at least 3 years now).
(2015-05-13, 10:19)Memphiz Wrote: [ -> ]At the point it fails there is no way to gracefully fallback to software. There are longwinded discussions about this burried in this forum already. Opening the VTB decoder works. (that is the real problem) - the errors are coming from the hardware during decoding then.

Trust me - if it was an easy task (i know it looks pretty easy from the outside) this would have been implemented already. (as this problem exists for at least 3 years now).

Believe me I trust the migthly Memphiz Cool - It's just a bit painful not being able to watch HD channels on a retina iPad.
Just one last thing I can think of, after that never pick this up again Angel: what if you would detect h264 interlaced video upfront and switch to SW before even trying HW?
there is no reliable easy way for detecting interlaced just from streamdata afaik. Something for mighty FernetMenta maybe.
Hmm, maybe a per-video/PVR channel toggle, like how we have per video/PVR-channel video settings? So you can toggle hardware or software decode in the OSD menu right along side deinterlacing and the other stuff. I'll make a post in the feature request forum.
osd is to late - not sure howto teardown playback and restart it at that point
(2015-05-14, 08:42)Memphiz Wrote: [ -> ]osd is to late - not sure howto teardown playback and restart it at that point

Indeed OSD is too late, mainly because there won't be any video window to show an OSD Big Grin
If we can find a way to detect interlaced video upfront that can be a good solution and far user friendly than having to set it up somewhere for each channel manually.
I used MediaInfo for one of my recorded programs and eureka it contains an indicator for interlaced!

Scan type : Interlaced


Code:
General
ID                                       : 2 (0x2)
Complete name                            : /Volumes/pvr/The Island with Bear Grylls/The Island with Bear Grylls (The Men's Island - S2E10PP)_Channel 4 HD_2015-05-13_22-00.ts
Format                                   : MPEG-TS
File size                                : 4.50 GiB
Duration                                 : 1h 7mn
Overall bit rate mode                    : Variable
Overall bit rate                         : 9 610 Kbps

Video
ID                                       : 511 (0x1FF)
Menu ID                                  : 3 (0x3)
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format version                           : Version 2
Format profile                           : Main@L4
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : 27
Duration                                 : 1h 6mn
Bit rate                                 : 8 554 Kbps
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 25.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Interlaced
Scan order                               : Top Field First
Bits/(Pixel*Frame)                       : 0.165
Stream size                              : 4.00 GiB (89%)
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Not all services will set that flag, but it's a good start and I have the feeling that most channels do have this flag.
Found a good read on detecting interlaced video with ffmpeg over here: http://www.aktau.be/2013/09/22/detecting...th-ffmpeg/

Quote:It turns out that ffmpeg has a filter called idet that (tries to) detect interlaced frames, and in my experience is quite good at it.

Possible pseudo solution - before playing a file:
Code:
IF device = problem with interlaced h264  && hwaccel = ON
{
  if (ffprobe"Scan type" == 'Interlaced')
  {
    switch to SW decoding
  }
  else if (idet tool == interlaced)
    switch to SW decoding
  }
}
- Check for interlaced is only tested on platforms that have this known issue
- Check for flag first and only test using ffmpeg idet tool if flag is not set
(2015-05-13, 10:19)Memphiz Wrote: [ -> ]At the point it fails there is no way to gracefully fallback to software. There are longwinded discussions about this burried in this forum already. Opening the VTB decoder works. (that is the real problem) - the errors are coming from the hardware during decoding then.

Trust me - if it was an easy task (i know it looks pretty easy from the outside) this would have been implemented already. (as this problem exists for at least 3 years now).

Have you read my last post? Don't you think that might work?

So the solution in my head is something like this:
1. Check if HW acceleration is on and store setting
2. Check for interlaced is only tested on platforms that have this known issue
3. Tune and get stream + if H264 Check for flag first and only test using ffmpeg idet tool if flag is not set
4. Disable hw acceleration if it's interlaced video
5. Play stream
6. Restore HW acceleration setting
Yes i have read it. As i am the only ios developer here and am really busy with RL atm - please try to find someone who could contribute the needed bits. Based on your solution in your head - i am not sure if this will work. Detecting interlaced FRAMES would mean that you need to decode them first. We want to detect interlaced material out of the metadata of the stream BEFORE even trying to decode it.

Also as you mentioned already - idet is a filter. A filter is way too late in the chain of decoding for beeing usefull here imo. Well that said - i really don't have time to look into it and the priority is really low (in the case i find some time).

The iOS Section is really in the need of contributors - but there are only slackers here which once they found out how to compile the beast - just do it for their own usage instead of contributing.