Skip to content

Instantly share code, notes, and snippets.

@leso-kn
Last active February 17, 2025 19:28
Show Gist options
  • Save leso-kn/1f12d794df5bb1471aa7c2210f1e8669 to your computer and use it in GitHub Desktop.
Save leso-kn/1f12d794df5bb1471aa7c2210f1e8669 to your computer and use it in GitHub Desktop.
Use WidevineCDM on musl (native musl-browsers, uses gcompat only on libwidevinecdm.so)
#!/bin/sh
pulse=$(echo /tmp/pulse-*)
docker run --rm -ti \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /dev/dri:/dev/dri \
-v /run/user/$(id -u)/pulse:/run/pulse \
-v $pulse:$pulse \
alpine \
ash -c "
set -e
apk add firefox gcompat patchelf font-noto
# step 1: generate firefox profile
DISPLAY=:0 firefox -headless | while read lin; do pkill firefox; done
export ffprofile=\$(echo /root/.mozilla/firefox/*.default-release)
echo 'user_pref(\"media.eme.enabled\", true);user_pref(\"media.gmp-manager.updateEnabled\", true);' >> \$ffprofile/prefs.js
printf 'Installing widevine cdm'
# step 2: let firefox install Widevine
DISPLAY=:0 firefox -headless 'https://bitmovin.com/demos/drm' 2>/dev/null >/dev/null &
while ! stat \$ffprofile/gmp-widevinecdm/*/LICENSE.txt 2>/dev/null >/dev/null
do
printf '.'
sleep 1
done
sleep 1
pkill firefox
# step 3: patch firefox Widevine to import gcompat.so.0 (requires GMP-sandboxing to be disabled)
patchelf --add-needed /lib/libgcompat.so.0 \$ffprofile/gmp-widevinecdm/*/libwidevinecdm.so
MOZ_DISABLE_GMP_SANDBOX=1 DISPLAY=:0 firefox
ash
"
@quadraplat
Copy link

yea, probably the sandbox that is messing me up...
I can patch it just fine and place it the correct place, but cant get widevine content to play. would be super nice to not need to have a the same borwser installed twice just to watch netflix....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment