xbmc / inputstream.adaptive

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

[K20/K21] MPD: "Cannot extract PSSH/KID" in subtitles shutdowns playback fully #1448

Closed helllamer closed 6 months ago

helllamer commented 8 months ago

Bug report

All subtitles globally disabled in kodi.

But some of collection IPTV streams fails to play, with PSSH/KID error in subtitles stream (see log below). Also reproduceble in stable Kodi 20.

Describe the bug

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

Log snipped contains general info:

ile::Open - <https://htv-rrs.mts.ru/PLTV/88888888/224/3221228154/3221228154.mpd> Effective URL is https://cache01-fed.spb.cdn.kion.ru/PLTV/88888888/224/3221228154/3221228154.mpd
og: inputstream.adaptive: Download finished: https://htv-rrs.mts.ru/PLTV/88888888/224/3221228154/3221228154.mpd (downloaded 9240 byte, speed 16135.00 byte/s)
og: inputstream.adaptive: Manifest saved to: /var/lib/kodi/.kodi/userdata/addon_data/inputstream.adaptive/manifests/manifest_1704312960.txt
og: inputstream.adaptive: Manifest successfully parsed (Periods: 1, Streams in first period: 3, Type: live)
og: inputstream.adaptive: New period, dispose sample decrypter and reinitialize
og: inputstream.adaptive: Entering encryption section
og: inputstream.adaptive: Initialize: CDM version: 4.10.2557.0
og: inputstream.adaptive: OnInitialized: CDM is initialized: true
og: inputstream.adaptive: Created AdaptiveStream [AS-0] with adaptation set ID: "3", stream type: subtitle
le::Open - <https://cache01-fed.spb.cdn.kion.ru/PLTV/88888888/224/3221228154/subtitles_init.m4i?hw_dash=1&servicetype=1&nil>
cquire - Created session to https://cache01-fed.spb.cdn.kion.ru
og: inputstream.adaptive: [AS-0] Download finished: https://cache01-fed.spb.cdn.kion.ru/PLTV/88888888/224/3221228154/subtitles_init.m4i?hw_dash=1&servicetype=1&nil (downloaded 751 byte, speed 4840.00 byte/s
og: inputstream.adaptive: License data: Cannot extract PSSH/KID data from the stream
og: inputstream.adaptive: Initializing stream with KID: d5e8f2aa3a56ecf09dde0088eaaf19b5
og: inputstream.adaptive: Initialize failed (SingleSampleDecrypter)
Player::OpenInputStream - error opening [pvr://channels/tv/%d0%92%d1%81%d0%b5%20%d0%ba%d0%b0%d0%bd%d0%b0%d0%bb%d1%8b@-1/1@pvr.iptvsimple_686388455.pvr]
Player::OnExit()
og: inputstream.adaptive: Close()
N:UnloadDll(/usr/lib/kodi/addons/inputstream.adaptive/inputstream.adaptive.so.21.4.1)

For full log, see GIST files: https://gist.github.com/helllamer/6ee0ce2bcca1eb2608752d7ce7352429

File iptv.m3u contains two example WV-protected MPD streams

Also, kodi 20 shows similar error

info <general>: AddOnLog: pvr.iptvsimple: pvr.iptvsimple - GetChannelStreamProperties - Live Stream URL: https://htv-rrs.mts.ru/PLTV/88888888/224/3221228154/3221228154.mpd
info <general>: Creating InputStream
info <general>: AddOnLog: inputstream.adaptive: [Repr. chooser] Resolution set: 1920x1080, max allowed: 1920x1080, Adjust refresh rate: 0
info <general>: AddOnLog: inputstream.adaptive: Successfully parsed manifest file (Periods: 1, Streams in first period: 3, Type: live)
error <general>: AddOnLog: inputstream.adaptive: Could not extract license from video stream (PSSH not found)
info <general>: ADDON: Dll Destroyed - InputStream Adaptive

Expected Behavior

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

  1. (crit) Stream https://htv-rrs.mts.ru/PLTV/88888888/224/3221228154/3221228154.mpd should just play, and subtitles error MUST NOT affect audio and video.
  2. (maybe) Subtitles of stream 3221228154.mpd should be properly decrypted.
  3. (feature-request) Also, if subtitles disabled in kodi settings, inputstream.adaptive must not do useless work for subtitles download, decryption and processing.

Actual Behavior

  1. Stream https://htv-rrs.mts.ru/PLTV/88888888/224/3221228154/3221228154.mpd fails to decrypt subtitles PSSH/KID, and everything fails without any audio/video works.
  2. Disabling/enabled subtitles does nothing in this situation.
  3. For comparison, other MPD in playlist attached playbacks ok.

Possible Fix

try { subtitlesInit() } catch { logger.error(); }

To Reproduce

Steps to reproduce the behavior:

  1. Use provided GIST to collect basic information.
  2. Possibly, use VPN inside Russia to access video-service.
  3. Use playlist from GIST to reproduce the problem. First stream will fail to play. Second stream -- will just work (for comparison).

Debuglog

The debuglog can be found here: https://gist.github.com/helllamer/6ee0ce2bcca1eb2608752d7ce7352429#file-kodi-log

MPD/M3U8s/ISM

An example or copy of a manifest (or manifests for HLS - master and variants) can be found here: https://gist.github.com/helllamer/6ee0ce2bcca1eb2608752d7ce7352429#file-iptv-m3u

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.

CastagnaIT commented 7 months ago

iirc currently encrypted subtitles are not supported i think for now we can implement the possibility to ignore stream having encrypted subtitles so at least you can play the video

helllamer commented 7 months ago

@CastagnaIT Sounds perfectly!

If you need any fresh URLs, keys or some other information -- feel free to tag me.

CastagnaIT commented 7 months ago

thanks for the sample streams, that we can use to do local tests, i made the fix, but please note that your streams could stall/freeze after some secs is a know ISA problem not solved yet

helllamer commented 7 months ago

Wow, it works! Test results in PR comment.

Thank you. Fixed!

CastagnaIT commented 6 months ago

reopened since by chance i found where is the problem... encrypted subtitles are supported for the MP4 container and this is the case, so i was wrong

both AdaptationSet and Representation have ContentProtection but the last one have only the default_KID this cause that create two PSSHSet one with empty pssh value, this cause the error Could not extract license from video stream (PSSH not found) since its missing the pssh, last time i havent realized this

<?xml version="1.0" encoding="UTF-8"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="dynamic" availabilityStartTime="2023-12-19T22:25:15Z" publishTime="2024-03-05T12:33:40Z" minimumUpdatePeriod="PT30S" timeShiftBufferDepth="PT64.0S" minBufferTime="PT1S" maxSegmentDuration="PT2S">
    <Period id="1" start="PT0S">
        <AdaptationSet id="3" lang="rus" contentType="text" segmentAlignment="true" mimeType="application/mp4" startWithSAP="1">
            <Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
            <SegmentTemplate timescale="10000000" duration="20000000" startNumber="1" media="$RepresentationID$_$Number$.m4s?hw_dash=1&amp;servicetype=1&amp;nil" initialization="$RepresentationID$_init.m4i?hw_dash=1&amp;servicetype=1&amp;nil"/>
            <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="d5e8f2aa-3a56-ecf0-9dde-0088eaaf19b5"/>
            <ContentProtection xmlns:mspr="urn:microsoft:playready" value="MSPR 2.0" schemeIdUri="urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95">
                <cenc:pssh>AAADPnBzc2gAAAAAmgTweZhAQoarkuZb4IhflQAAAx4eAwAAAQABABQDPABXAFIATQBIAEUAQQBEAEUAUgAgAHgAbQBsAG4AcwA9ACIAaAB0AHQAcAA6AC8ALwBzAGMAaABlAG0AYQBzAC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAEQAUgBNAC8AMgAwADAANwAvADAAMwAvAFAAbABhAHkAUgBlAGEAZAB5AEgAZQBhAGQAZQByACIAIAB2AGUAcgBzAGkAbwBuAD0AIgA0AC4AMAAuADAALgAwACIAPgA8AEQAQQBUAEEAPgA8AFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBFAFkATABFAE4APgAxADYAPAAvAEsARQBZAEwARQBOAD4APABBAEwARwBJAEQAPgBBAEUAUwBDAFQAUgA8AC8AQQBMAEcASQBEAD4APAAvAFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBJAEQAPgBxAHYATABvADEAVgBZADYAOABPAHkAZAAzAGcAQwBJADYAcQA4AFoAdABRAD0APQA8AC8ASwBJAEQAPgA8AEMASABFAEMASwBTAFUATQA+AHAASgBPAEkAVwBEAGcAYgB5AFIAOAA9ADwALwBDAEgARQBDAEsAUwBVAE0APgA8AEwAQQBfAFUAUgBMAD4AaAB0AHQAcABzADoALwAvAGgAdAB2AC0AcAByAGwAcwAuAG0AdABzAC4AcgB1AC8AUABsAGEAeQBSAGUAYQBkAHkALwByAGkAZwBoAHQAcwBtAGEAbgBhAGcAZQByAC4AYQBzAG0AeAA8AC8ATABBAF8AVQBSAEwAPgA8AEwAVQBJAF8AVQBSAEwAPgBoAHQAdABwAHMAOgAvAC8AaAB0AHYALQBwAHIAbABzAC4AbQB0AHMALgByAHUALwBQAGwAYQB5AFIAZQBhAGQAeQAvAHIAaQBnAGgAdABzAG0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAFUASQBfAFUAUgBMAD4APAAvAEQAQQBUAEEAPgA8AC8AVwBSAE0ASABFAEEARABFAFIAPgA=</cenc:pssh>
            </ContentProtection>
            <ContentProtection value="Widevine" schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
                <cenc:pssh>AAAAWXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADkIARIQ1ejyqjpW7PCd3gCI6q8ZtRoNdmVyaW1hdHJpeG10cyINcj02NTQwNiZzPTk1MyoFU0RfSEQ=</cenc:pssh>
            </ContentProtection>
            <Representation id="subtitles" bandwidth="3200" codecs="stpp">
                <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="d5e8f2aa-3a56-ecf0-9dde-0088eaaf19b5"/>
            </Representation>
        </AdaptationSet>
...

as test i tried force merge both PSSHSet's and i can play video with encrypted subtitles with success i also noticed another problem when you disable/re-enable subtitles from GUI OSD subtitles are broken

i will try to provide a better solution