xbmc / inputstream.adaptive

kodi inputstream addon for several manifest types
Other
453 stars 242 forks source link

macOS/arm64: Loading of widevine fails, unable to play DRM-protected content #1481

Closed herrnst closed 9 months ago

herrnst commented 9 months ago

Bug report

Describe the bug

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

Kodi running on macOS Sonoma 14.3.1 on a MacMini M1, arm64 build, updated to latest nightly (kodi-20240219-cf9bb1f7-master-3621-arm64.dmg, though the issue is present since the first time I installed Kodi/arm64 on this system).

Playback of DRM-protected content (using widevine) via any video addon (tested Netflix and DAZN) fails with "Generic failure during playback". From kodi.log (see below) it appears as if libwidevinecdm isn't correctly handled and/or used as IA tries to load libwidevinecdm.so instead of libwidevinecdm.dylib.

The widevine library itself seems to be correctly installed to ~/Library/Application Support/Kodi/cdm/ by the inputstream helper script addon:

$ ls -al ~/Library/Application\ Support/Kodi/cdm
total 34640
drwxr-xr-x@  6 username  staff       192 25 Jan 17:50 .
drwxr-xr-x@ 10 username  staff       320 25 Jan 17:45 ..
-rw-r--r--@  2 username  staff       479 25 Jan 17:45 LICENSE.txt
-rw-r--r--@  2 username  staff  17722576 25 Jan 17:45 libwidevinecdm.dylib
-rw-r--r--@  2 username  staff      1427 25 Jan 17:45 libwidevinecdm.dylib.sig
-rw-r--r--@  2 username  staff       374 25 Jan 17:45 manifest.json

and is an arm64 binary:

$ file ~/Library/Application\ Support/Kodi/cdm/libwidevinecdm.dylib
Library/Application Support/Kodi/cdm/libwidevinecdm.dylib: Mach-O 64-bit dynamically linked shared library arm64

Though on any playback attempt, IA logs:

error <general>: AddOnLog: inputstream.adaptive: Unable to load widevine shared library (/Users/username/Library/Application Support/Kodi/cdm/libwidevinecdm.so)

I also blindly tried symlinking the .dylib files to .so, to no avail.

Expected Behavior

Playback of DRM-protected content works as on other platforms (ie. Linux/x86_64, Windows, Linux/armv7 via LibreElec on a RPI etc).

Actual Behavior

Playback fails with a "Generic" playback error popup.

Possible Fix

Maybe something in the line of correctly handling libwidevinecdm.dylib on arm64, no idea really.

To Reproduce

Steps to reproduce the behavior:

  1. Install Kodi arm64 build on Apple arm-hardware, install IA, install any video addon for any streaming service (ie. Netflix, DAZN, other), configure as usual (ie. IA settings, credentials in the addon etc)
  2. Play any DRM-protected media
  3. Playback error popup appears

Debuglog

Relevant excerpt from kodi.log with debugging enabled (hope thats fine):

2024-02-19 11:21:03.248 T:64091    info <general>: AddOnLog: inputstream.adaptive: Manifest successfully parsed (Periods: 1, Streams in first period: 2, Type: VOD)
2024-02-19 11:21:03.248 T:64091   debug <general>: AddOnLog: inputstream.adaptive: [Repr. chooser] Stream selection conditions
                                                   Screen resolution: 2560x1440 (may be limited by settings)
                                                   Initial bandwidth: 16390291 bit/s
2024-02-19 11:21:03.248 T:64091   debug <general>: AddOnLog: inputstream.adaptive: New period, dispose sample decrypter and reinitialize
2024-02-19 11:21:03.248 T:64091   debug <general>: AddOnLog: inputstream.adaptive: Entering encryption section
2024-02-19 11:21:03.248 T:64091   error <general>: AddOnLog: inputstream.adaptive: Initialize: Initialize: Failed to load library: 
2024-02-19 11:21:03.248 T:64091   error <general>: AddOnLog: inputstream.adaptive: Unable to load widevine shared library (/Users/username/Library/Application Support/Kodi/cdm/libwidevinecdm.so)
2024-02-19 11:21:03.248 T:64091   error <general>: AddOnLog: inputstream.adaptive: OpenDRMSystem failed
2024-02-19 11:21:03.248 T:64091   debug <general>: AddOnLog: inputstream.adaptive: CSession::~CSession()
2024-02-19 11:21:03.249 T:64091   error <general>: CVideoPlayer::OpenInputStream - error opening [...]]
2024-02-19 11:21:03.249 T:64091    info <general>: CVideoPlayer::OnExit()

MPD/M3U8s/ISM

An example or copy of a manifest (or manifests for HLS - master and variants) can be found here:

(applies to any Manifest/HLS/MPD/M3U)

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.

CastagnaIT commented 9 months ago

here you can find the fix test build: https://jenkins.kodi.tv/blue/organizations/jenkins/xbmc%2Finputstream.adaptive/detail/PR-1482/1/artifacts please give a feedback

herrnst commented 9 months ago

here you can find the fix test build: https://jenkins.kodi.tv/blue/organizations/jenkins/xbmc%2Finputstream.adaptive/detail/PR-1482/1/artifacts please give a feedback

Wow, that was quick ;) Thanks!

With that build, things work as expected, on the same macOS/arm64 Kodi build, though just tried a few stream from DAZN.

This is what kodi.log looks like now:

2024-02-19 13:20:58.606 T:126147    info <general>: AddOnLog: inputstream.adaptive: Manifest successfully parsed (Periods: 1, Streams in first period: 2, Type: live)
2024-02-19 13:20:58.606 T:126147   debug <general>: AddOnLog: inputstream.adaptive: [Repr. chooser] Stream selection conditions
                                                   Screen resolution: 2560x1440
2024-02-19 13:20:58.606 T:126147   debug <general>: AddOnLog: inputstream.adaptive: New period, dispose sample decrypter and reinitialize
2024-02-19 13:20:58.606 T:126147   debug <general>: AddOnLog: inputstream.adaptive: Entering encryption section
2024-02-19 13:20:58.606 T:126147   debug <general>: AddOnLog: inputstream.adaptive: Initialize: CDM version: 4.10.2710.0
2024-02-19 13:20:58.606 T:126147   debug <general>: AddOnLog: inputstream.adaptive: OnInitialized: CDM is initialized: true
2024-02-19 13:20:58.606 T:126147   debug <general>: AddOnLog: inputstream.adaptive: Initializing stream with KID: hidden
2024-02-19 13:20:58.640 T:126147   debug <general>: AddOnLog: inputstream.adaptive: CDMMessage: 1 arrived!
2024-02-19 13:20:58.640 T:126147   debug <general>: AddOnLog: inputstream.adaptive: SetSession: Opened widevine session ID: hidden
[cont'ed with all the expected keyexchange and setup of player cores]

Will test more and report back, but that looks like its fixed.

Thanks!

EDIT/Addendum: Was about to check against Netflix and unfortunately just fell over https://github.com/CastagnaIT/plugin.video.netflix/issues/1585 so getting only audio but no video, but I guess this indicates libwidevine by itself is working...