xbmc / inputstream.adaptive

kodi inputstream addon for several manifest types
Other
452 stars 241 forks source link

Choppy 4K HDR10(+) video on Android TV in Amazon VOD addon #1197

Closed MauriceW67 closed 1 year ago

MauriceW67 commented 1 year ago

Bug report

Describe the bug

Here is a clear and concise description of what the problem is:

When playing 4K HDR10(+) video from the Amazon VOD addon, the video is very choppy. If I turn off the HDR10+ option in the addon, the 4K version plays fine in SDR HEVC. Tested with various episodes of The Boys Season 3 and Reacher Season 1.

Note 1: 4K Dolby Vision plays fine (tested with Lord of the Rings: The Rings of Power).

Note 2: This does not only happen on my Philips TV, but also on the Nvidia Shield Pro 2019. And it also happens on Kodi 20.1 Nexus, so not just on Kodi 21 master.

Note 3: @CastagnaIT asked if the debug info shows any corrections. The answer is no. During the choppy video the skip and audio correction counters don't increase. The audio does have some dropouts, but not at every video skip though.

Note 4: This issue was first created in the Amazon VOD GitHub, but @glennguy has requested me to create it here as well.

Expected Behavior

Here is a clear and concise description of what was expected to happen:

4K HDR10+ videos playing smoothly in the Amazon VOD addon.

Actual Behavior

4K HDR10+ videos play very choppily.

Possible Fix

To Reproduce

Steps to reproduce the behavior:

  1. Enable the HDR10+ option in the Amazon VOD addon
  2. Play a TV show episode that is available in HDR10+ such as The Boys season 3 or Reacher season 1
  3. Notice the choppy video

Debuglog

The debuglog can be found here: Debug log of 4K HDR10+ video playing: https://paste.kodi.tv/azeviduwov.kodi (part 1) and https://paste.kodi.tv/wojudozeko.kodi (part 2) Debug log of same episode playing in 4K SDR: https://paste.kodi.tv/bajihivozu.kodi

MPD/M3U8s/ISM

An example or copy of a manifest (or manifests for HLS - master and variants) can be found here: Manifest files were too big for Kodi pastebin, so I zipped them up here: https://drive.google.com/file/d/1KhVRliJaModP5-fGibdxO42N107iMBO1/view?usp=share_link

manifest_1679331240_hdr10.txt manifest_1679334649_sdr.txt

Screenshots

Here are some links or screenshots to help explain the problem:

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

Your Environment

Used Operating system:

note: Once the issue is made we require you to update it with new information should that be required. Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.

MauriceW67 commented 1 year ago

@glennguy @CastagnaIT Any chance of one of you taking a look and see what's causing this? :)

CastagnaIT commented 1 year ago

atm im busy with the rework but on hdr log i see a lot of DEMUX_SPECIALID_STREAMCHANGE im not sure if its correct where on the non-hdr log there are no, when DEMUX_SPECIALID_STREAMCHANGE event happens may cause a delays in kodi because reinitialize a lot of things

could be useful to know if the problem happens also on Kodi 19 and 20.

@Varstahl not related to this problem but i noticed in the amazon manifest (20mb of manifest they are crazy?) there are under AdaptationSet tag, SegmentDurations tag can you provide me some info about SegmentDurations tag? its a custom your addon implementation or its an untouched amazon manifest? i ask because i workin on ISAdaptive rework and i was going to delete this support since i havent found SegmentDurations tag specs around the web

same for codecPrivateData attribute on Representation tag

MauriceW67 commented 1 year ago

@CastagnaIT I did not check on Kodi 19, but on Kodi 20.1 the same issue occurs. I will try to get a log of that one as well.

MauriceW67 commented 1 year ago

@CastagnaIT I created a log with Kodi Nexus 20.1 and ISA 20.3.5. It was too big so I split it into two:

https://paste.kodi.tv/ukavuriyif.kodi https://paste.kodi.tv/efiditurac.kodi

Same choppiness of the video. Same DEMUX_SPECIALID_STREAMCHANGE log entries as Kodi Omega.

(The log is from a Kodinerds 20.1 build from Maven, but that should not matter for this case)

pmsobrado commented 1 year ago

I can confirm the same behaviour, with HDR disabled it does not happen. Other thing I've noticed is that Kodi set the TV ouput for "The Boys" content at 4K/60Hz. Not that it has anything to do with this issue, but for any other content Kodi sets my TV output to 24 or 50Hz. My device is a Fire TV 4K Max.

CastagnaIT commented 1 year ago

@MauriceW67 can you provide a new log? all logs has been wiped out due to kodi website data breach

MauriceW67 commented 1 year ago

@CastagnaIT I updated the opening post with new log links.

I had to split the HDR10 log, because it seems Kodi's paste size limit has decreased from what it was before.

CastagnaIT commented 1 year ago

i have prepared a modified version in the hope to have more log details please install it and provide a new log for hdr

i dont know what version you use aarch64? inputstream.adaptive-android-aarch64-omega-95058ea.zip inputstream.adaptive-android-armv7-omega-95058ea.zip

you can drag n drop the new log file directly when you write the message here, so you can avoid pastebin

MauriceW67 commented 1 year ago

@CastagnaIT I use 64-bit on the Shield Pro 2019.

But with your test version Kodi immediately exits without any message. Went back to the release version 21.1.0 and the video plays again (with chopping).

Log file from crashed Kodi is attached.

kodi.log

CastagnaIT commented 1 year ago

i will need to get an amazon account to investigate first on "exits" crash problem after that we will try again understand this

glennguy commented 1 year ago

@CastagnaIT One place to look is to check here if this condition is returning true: https://github.com/xbmc/inputstream.adaptive/blob/27ffa26a21859924049b8df698319440ac41ae98/src/samplereader/FragmentedSampleReader.cpp#L230-L237

This flows through to the session and sets the flag that the stream has changed and IA instructs VP to reset.

The mp4 files are accessible so I had a look and they contain a lot of sample description boxes in the initialization: image

These are almost identical except that the nalu arrays in the hvcC boxes differ slightly. This shouldn't affect us as we always ask for the first sample description box, but....

Each of the tfhd boxes in each segment's moof has a sample description index that seems to be random after initially incrementing.

So this changing of sample description index and with each of them having small changes in extradata is what's causing the stream change to be triggered on each segment.

I don't know about the nalu array values, but I wonder if we really need to be reinitializing the player every time that changes, because the rest of the sample description is exactly the same. The method for comparing them is only looking at the raw data, I wonder if bento4 has something better....

CastagnaIT commented 1 year ago

i think we dont care about nalu or extradata on how is implemented DEMUX_SPECIALID_STREAMCHANGE on kodi core is currently too expensive imo we could limit sending DEMUX_SPECIALID_STREAMCHANGE only when codec and/or codec profile change while in playback, and remove all other checks and see how works

make a test by commenting all relevants m_changed = true; on session.cpp and check if there are hdr problems when in playback

glennguy commented 1 year ago

@MauriceW67 would you be able to try test build from here https://jenkins.kodi.tv/blue/organizations/jenkins/xbmc%2Finputstream.adaptive/detail/PR-1251/1/artifacts ?

MauriceW67 commented 1 year ago

@glennguy Unfortunately with this test build Kodi exhibits the same behavior as with @CastagnaIT 's previous test build. It crashes to the Android TV homescreen right after selecting the desired resolution. No error message is displayed.

Tested both versions: 32-bit on my Philips TV and 64-bit on the Shield 2019 Pro.

Tested with Kodi Omega nightly kodi-20230506-eebc7146-master

See attached debug log.

kodi.log

glennguy commented 1 year ago

Thanks for testing, I've reproduced the crash in part and pushed a fix to the test PR.

Could you try a build from here when you get a chance? - https://jenkins.kodi.tv/blue/organizations/jenkins/xbmc%2Finputstream.adaptive/detail/PR-1251/2/artifacts/

MauriceW67 commented 1 year ago

@glennguy Thank you, that version seems to have solved the choppiness!

Tested also with DV content (LOTR) and that still works too. Also tested some other addons. Disney+ addon (Mandalorian, DV) still worked. Netflix addon doesn't work because of some weird login issue unfortunately (but that has nothing to do with this issue).

Kampfader commented 1 year ago

I confirm this hdr10+ fix. I have testet this on fire tv cube. Kodi 21.0 (2023.05.04) But another bug crept in. I tested it against official v21.1.0

Fast forward = wait max 2sec = no sound! Back forward = wait max 20sec = sound is back

Primevideo, Serie The Boys, Season 3

CastagnaIT commented 1 year ago

But another bug crept in. I tested it against official v21.1.0

please open another issue for other type bugs and provide issue template info

MauriceW67 commented 1 year ago

I have to agree with @Kampfader audio is lost for quite a bit of time after seeking in this test version. Eventually it fixes itself, but it seems to have started with this test version.

CastagnaIT commented 1 year ago

the last kodi 21 ISA release version has old code without all the new reworks then there are ton of changes included with the "test" version, so please open a new separate Issue for audio problem and provide logs as usual

try test this new build for choppy problem: https://jenkins.kodi.tv/blue/organizations/jenkins/xbmc%2Finputstream.adaptive/detail/PR-1253/1/artifacts let me know how works

Kampfader commented 1 year ago

@CastagnaIT No choppy problem here, thanks

Kampfader commented 1 year ago

I've tested it more now. The last version of @CastagnaIT also hangs and completely crashes kodi. After restarting the device (not kodi) it works again a few times.

Debuglog https://paste.kodi.tv/oqusoyolof.kodi

Manifestfile

Ronny-nerd commented 1 year ago

Vielen Dank für den Test. Ich habe den Absturz teilweise reproduziert und einen Fix in die Test-PR übernommen.

Könnten Sie bei Gelegenheit einen Build von hier aus ausprobieren? - https://jenkins.kodi.tv/blue/organizations/jenkins/xbmc%2Finputstream.adaptive/detail/PR-1251/2/artifacts/

I would have liked to test this PR version of Inpustream Adaptive...unfortunately it can no longer be downloaded.

Hardware: Nvidia Shield TV Pro 2019

I have problems with the other newer versions.

Kampfader commented 1 year ago

Here, the is from @glennguy https://mega.nz/file/XU9ywD5R#cf0CHxr3nbdyfLD67vN2sBPezQ7wTsOjxm8UNJQSHIo

CastagnaIT commented 1 year ago

i am trying testing amazon vod on a 30 days trial account on a shield i have login and enabled 4k and hdr from amazon addon settings playback works but i dont have nor 4k and nor hdr available, some suggest?

MauriceW67 commented 1 year ago

@CastagnaIT Did you also enable the option "Register device for 4K playback" in the Connection menu of the addon?

If you did and it worked, you should see a device being added in your account settings page on the Prime Video website.

MauriceW67 commented 1 year ago

I see that the possible fix for the choppiness didn't make it into the new 21.1.1 release :)

@CastagnaIT Did you already manage to get 4K working in the Amazon VOD addon? If not, you could try to set the region in the addon to UK. That used to work for me with older versions of the addon, although it's not required anymore since versio 0.98 (at least for my Dutch account).

If you need any new logs or something, let me know.

CastagnaIT commented 1 year ago

Did you also enable the option "Register device for 4K playback" in the Connection menu of the addon?

i think forgot it, i will need to relogin when i will have the next opportunity to test on a hdr tv in hoping to catch the crash unfurnately logs are not so useful when kodi crashes

MauriceW67 commented 1 year ago

I understand. But please note that the second fix that @glennguy posted here:

https://github.com/xbmc/inputstream.adaptive/issues/1197#issuecomment-1537434428

Did not crash Kodi and fixed the choppiness (for me at least).

CastagnaIT commented 1 year ago

yes i know but was a test, comment out just part of code and leaving half an implementation to chance is not a good solution

Kampfader commented 1 year ago

i make here one crash logcat from fire cube "adb shell logcat"

https://paste.sensio.no/TallerNoticing can you see something there?

i play The Boys S01E01

CastagnaIT commented 1 year ago

After a bit of hours i think to have found and fixed the problems, at the end are not related to current changes done here but that has been introduced with the many new previous code refactors, the crash is due to lost memory pointers where its possible "workaround" the crash bug by set a fixed video quality to ISA settings the crash also can happens on other operative systems but depends also on streams provided

Here android test builds: inputstream.adaptive-android-armv7-omega-70639db.zip inputstream.adaptive-android-aarch64-omega-70639db.zip

I was able to do the 4k HDR test successfully i hope it work well now please let me know

Kampfader commented 1 year ago

Thanks @CastagnaIT for you hard work.

Im testing on armv7 (cube) Everything works perfectly

I tested several series, there are no crashes. No Choppy problems. No Sound problems, after jump -10min (button down on the remote control)

I'm curious if it works for other people too.

CastagnaIT commented 1 year ago

since on two different android devices works there is good chance that fix works for all users thanks for your support

pmsobrado commented 1 year ago

After a bit of hours i think to have found and fixed the problems, at the end are not related to current changes done here but that has been introduced with the many new previous code refactors, the crash is due to lost memory pointers where its possible "workaround" the crash bug by set a fixed video quality to ISA settings the crash also can happens on other operative systems but depends also on streams provided

Here android test builds: inputstream.adaptive-android-armv7-omega-70639db.zip inputstream.adaptive-android-aarch64-omega-70639db.zip

I was able to do the 4k HDR test successfully i hope it work well now please let me know

I'm using Kodi 19 and a Fire TV 4K Max, how can I satisfy kodi.binary.global.main and the other dependencies?

Kampfader commented 1 year ago

Forget it, kodi 19 still runs on python2.
From kodi20 everything is rewritten to python3.

You only have one option. Reinstall Kodi20 fresh, please do not update from 19 to 20.

MauriceW67 commented 1 year ago

Tested 64-bit on my Shield 2019 Pro and 32-bit on my Philips Android TV. Both play HDR from Amazon VOD without stuttering. Thanks for all the work you put in!

pmsobrado commented 1 year ago

Forget it, kodi 19 still runs on python2. From kodi20 everything is rewritten to python3.

You only have one option. Reinstall Kodi20 fresh, please do not update from 19 to 20.

Two questions:

1 - Why can't I update? Why reinstall from scratch? 2 - I read somewhere that Fire TV wasn't powerful enough for Kodi 20. Can anyone here confirm that Kodi 20 works fine on a Fire TV 4K Max?

CastagnaIT commented 1 year ago

1: in any case its always discouraged make a direct upgrade to new Kodi major versions (e.g. v19 to v20 or v19 to v21), because can produce weirdness in to kodi db and settings, leading to possible hidden malfunctions. If you are lucky the upgrade could end with success, otherwise you will need to reinstall kodi from scratch... different thing if you want upgrade to new minor versions then there is no problems e.g. 19.0 to 19.2 2: This sounds strange, statement never reached here

pmsobrado commented 1 year ago

I don't remember where, but sure, it wasn't here.