Got Firefox to play a DRM encrypted video

I just got Firefox to play a DRM encrypted video

Video of Firefox playing a widevine drm encrypted mpd

note i didnt record the audio ( audio works ) because i would have had to start virtual oss to capture the audio
and i wasnt sure if i would be get the drm video playing again


note you may need to be logged into google to view the video
i made it public but may still show a log into google page for you

i couldnt upload the video to Youtube
because i have a strike against me for making a video about Kodi and the youtube addon

Using this DRM Streaming Test page


firefox-widevine-[00:00:25.767]v1.jpg


I have the linux-widevine-cdm installed ( built with poudriere )

Im my Firefox profile

Code:
~/.mozilla/firefox/kd3khr3t.default-release/gmp-widevinecdm

there is a gmp-widevinecdm directory
inside that directory i recreated the files that are present on Firefox with drm enabled

output of tree in the gmp-widevinecdm directory

Code:
.
└── 4.10.2710.0
    ├── libwidevinecdm.so
    └── manifest.json

i copied the libwidevinecdm.so from this location

Code:
/usr/local/share/chromium/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so

libwidevinecdm.so is actually a symlink to fcdm-fbsd.so

Code:
libwidevinecdm.so -> /usr/local/lib/foreign-cdm/fcdm-fbsd.so

i copied the manifest.json from Firefox on linux

Code:
{
    "arch": "x64",
    "description": "Widevine Content Decryption Module",
    "manifest_version": 2,
    "name": "WidevineCdm",
    "os": "linux",
    "version": "4.10.2710.0",
    "x-cdm-codecs": "vp8,vp09,avc1,av01",
    "x-cdm-host-versions": "10",
    "x-cdm-interface-versions": "10",
    "x-cdm-module-versions": "4",
    "x-cdm-persistent-license-support": false
}

firefox settings

Code:
about:config

widevine settings i copied from linux


20240709_16h32m41s_grim.png


mpd url


try playing the mpd with mpv

Code:
mpv 'https://media.axprod.net/TestVectors/v6.1-MultiDRM-MultiKey/Manifest_1080p.mpd'

and it shouldnt play and you will get these errors in the terminal

Code:
Error decoding audio.
Error while decoding frame!

if you download the mpd file

Code:
wget 'https://media.axprod.net/TestVectors/v6.1-MultiDRM-MultiKey/Manifest_1080p.mpd'

and look inside the mpd file you will see if using Widevine drm encryption with the pssh key inside the mpd file

Code:
<ContentProtection value="Widevine" schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
  <cenc:pssh>AAAANHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABQIARIQFTDToGkERGqRoTOhFaqMQQ==</cenc:pssh>
</ContentProtection>

Just creating the 4.10.2710.0 directory and files in my firefox profiles gmp-widevinecdm directory
doesnt magically enable Firefox to play the video on the link at the top of the page

I managed to get Firefox to play the video a couple of time,
i was actually logged in itv.com ( which use drm ) and trying to play a video

The video on ITV didnt play
but the DRM Streaming Test in the other tab started to play the video

i couldnt get drm content on itv or channel 4 to work
im guessing the mpd played back in Firefox because the mpd contained the pssk key

I have also been playing around with Kodi which can play back drm content
with using kodi-addon-inputstream.adaptive

Code:
sudo pkg install kodi kodi-addon-inputstream.adaptive

create a file called widevine.strm
with this content which is the license key and mpd from the drm test page

Code:
#KODIPROP:inputstream=inputstream.adaptive
#KODIPROP:inputstream.adaptive.manifest_type=mpd
#KODIPROP:inputstream.adaptive.license_type=com.widevine.alpha
#KODIPROP:inputstream.adaptive.license_key=https://drm-widevine-licensing.axtest.net/AcquireLicense
https://media.axprod.net/TestVectors/v6.1-MultiDRM-MultiKey/Manifest_1080p.mpd

copy the widevine.strm file to the video playlist directory for kodi

Code:
cp widevine.strm ~/.kodi/userdata/playlists/video

copy the libwidevinecdm.so to the ~/.kodi/cdm directory
which is where it looks for the libwidevinecdm.so file

Code:
cp /usr/local/share/chromium/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so ~/.kodi/cdm

if you try play the widevine.strm in the kodi playlist directory with kodi,
kodi crashes, so no joy yet

the libwidevinecdm.so is too large to attach as a zip to this post
so if you want to try this out you need the linux-widevine-cdm port installed

and then copy the libwidevinecdm.so into place as described above
on freebsd 14.1 the xdg runtime dir is set to /var/run/xdg/username
where username is your username

inside the xdg runtime dir you will see the fcdm-jail and fcdm-lock directories
created by the linux-widevine-cdm port

Code:
# ls -l /var/run/xdg/djwilcox/
total 7
dr-xr-xr-x  2 djwilcox djwilcox 2  9 Jul 14:41 .fcdm-jail
-r--r--r--  1 djwilcox djwilcox 0  9 Jul 14:41 .fcdm-lock
srwxr-xr-x  1 djwilcox djwilcox 0  9 Jul 13:23 Alacritty-wayland-0-59988.sock
drwx------  2 djwilcox djwilcox 3  9 Jul 13:24 at-spi
drwx------  3 djwilcox djwilcox 3  9 Jul 13:23 dbus-1
drwx------  2 djwilcox djwilcox 3  9 Jul 17:52 dconf
drwx------  2 djwilcox djwilcox 2  9 Jul 13:24 doc
drwx------  2 djwilcox djwilcox 3  9 Jul 13:23 dwlb
drwx------  2 djwilcox djwilcox 3  9 Jul 13:24 emacs
drwx------  2 djwilcox djwilcox 2  9 Jul 13:24 pulse
-rw-------  1 djwilcox djwilcox 0  9 Jul 13:24 tofi.lock
srwxr-xr-x  1 djwilcox djwilcox 0  9 Jul 13:23 wayland-0
-rw-r-----  1 djwilcox djwilcox 0  9 Jul 13:23 wayland-0.lock
-rwx------  1 root     djwilcox 0  9 Jul 13:23 xdg_session.0
 
i havent been able to reproduce Firefox playing the drm video

When playing a drm video with chromium
the xdg runtime dir .fcdm-jail directory

Code:
/var/run/xdg/djwilcox/.fcdm-jail

is populated with these files and directories

Code:
# ls -al .fcdm-jail/
total 196
dr-xr-xr-x  11 djwilcox djwilcox 704  9 Jul 19:47 .
drwx------  10 djwilcox djwilcox  16  9 Jul 19:47 ..
-r--r--r--   1 root     djwilcox   0  9 Jul 19:47 .setup-done
-r--r--r--   1 root     djwilcox   0  9 Jul 19:47 .whatever
drwxr-xr-x   2 root     wheel    275 13 Apr 12:23 bin
dr-xr-xr-x  12 root     wheel    512  9 Jul 19:47 dev
drwxr-xr-x  27 root     wheel     67 13 Apr 12:23 etc
drwxr-xr-x  21 root     wheel    379 13 Apr 12:23 lib
drwxr-xr-x  13 root     wheel    387 13 Apr 12:23 lib64
dr-xr-xr-x   2 root     djwilcox 128  9 Jul 19:47 opt
dr-xr-xr-x   1 root     wheel      0  9 Jul 19:47 proc
dr-xr-xr-x   1 root     wheel      0  9 Jul 19:47 sys
drwxr-xr-x   8 root     wheel      9 13 Apr 12:23 usr

the fcdm-jail is only populated when playing drm content with chromium

using kodi to try playing back widevine content in a strm file
described in the post above doesnt result in the .fcdm-jail being populated with the files and directories listed above

when trying to play widevine content with kodi
the ~/.kodi/cdm/widevine directory is created with another directory listed below

Code:
  /home/djwilcox/.kodi/cdm/widevine:
  drwxr-xr-x 2 djwilcox djwilcox 2 Jul  9 19:48 68747470733A2F2F64726D2D7769646576696E652D6C6963656E73696E672E6178746573742E6E6574

then kodi crashes
looking in the kodi logs i can see the adaptive stream plugin parses the mpd file

kodi looks for the libwidevinecdm.so file in this location

Code:
~/.kodi/cdm/libwidevinecdm.so

without the libwidevinecdm.so in that location when you play a drm video with kodi it will fail
and the kodi log will show an error saying couldnt find libwidevinecdm.so in the location listed above

Code:
2024-07-09 20:59:31.699 T:234652    info <general>: VideoPlayer::OpenFile: special://profile/playlists/video/widevide-test.strm
2024-07-09 20:59:31.725 T:274270    info <general>: Creating InputStream
2024-07-09 20:59:31.778 T:274270    info <general>: AddOnLog: inputstream.adaptive: [Repr. chooser] Resolution set: 1908x1004, max allowed: 1908x1004, Adjust refresh rate: 0
2024-07-09 20:59:31.932 T:274270    info <general>: AddOnLog: inputstream.adaptive: Successfully parsed manifest file (Periods: 1, Streams in first period: 9, Type: VOD)
 
i think the widevinecdm.json url listed above is what Firefox uses
to download install the widevine plugin on linux, mac and windows

in firefox settings on those distros there is a check box to enable drm playback
and it i think it queries the widevinecdm.json url and then downloads and install the widevine plugin

you will notice freebsd isnt listed

the Linux_x86_64-gcc3 zip contains the libwidevinecdm.so and manifest.json

the manifest.json file look this

Code:
{
    "arch": "x64",
    "description": "Widevine Content Decryption Module",
    "manifest_version": 2,
    "name": "WidevineCdm",
    "os": "linux",
    "version": "4.10.2710.0",
    "x-cdm-codecs": "vp8,vp09,avc1,av01",
    "x-cdm-host-versions": "10",
    "x-cdm-interface-versions": "10",
    "x-cdm-module-versions": "4",
    "x-cdm-persistent-license-support": false
}

whereas the manifest.json from the linux-widevine-cdm looks like this

Code:
Yes Master ? ls -l /usr/local/share/chromium/WidevineCdm
total 1
drwxr-xr-x  3 root wheel  3  1 Dec  2023 _platform_specific
lrwxr-xr-x  1 root wheel 40 12 Jan 02:40 manifest.json -> /usr/local/lib/WidevineCdm/manifest.json

Code:
{
  "manifest_version": 2,
  "update_url": "https://clients2.google.com/service/update2/crx",
  "name": "WidevineCdm",
  "description": "Widevine Content Decryption Module",
  "version": "4.10.2710.0",
  "minimum_chrome_version": "68.0.3430.0",
  "x-cdm-module-versions": "4",
  "x-cdm-interface-versions": "10",
  "x-cdm-host-versions": "10",
  "x-cdm-codecs": "vp8,vp09,avc1,av01",
  "x-cdm-persistent-license-support": false,
  "x-cdm-supported-encryption-schemes": [
    "cenc",
    "cbcs"
  ],
  "icons": {
    "16": "imgs/icon-128x128.png",
    "128": "imgs/icon-128x128.png"
  },
  "platforms": [
    {
      "os": "linux",
      "arch": "x64",
      "sub_package_path": "_platform_specific/linux_x64/"
    },
    {
      "os": "linux",
      "arch": "arm64",
      "sub_package_path": "_platform_specific/linux_arm64/"
    }
  ]
}
 
The drm video is playing again in Firefox

I have chromium open playing the drm video

20240709_21h47m22s_grim.png


you can see the contents of the fcdm-jail while the video is playing in chromium

Code:
# ls -al .fcdm-jail/
total 196
dr-xr-xr-x  11 djwilcox djwilcox 704  9 Jul 21:26 .
drwx------  10 djwilcox djwilcox  16  9 Jul 21:45 ..
-r--r--r--   1 root     djwilcox   0  9 Jul 21:26 .setup-done
-r--r--r--   1 root     djwilcox   0  9 Jul 21:26 .whatever
drwxr-xr-x   2 root     wheel    275 13 Apr 12:23 bin
dr-xr-xr-x  12 root     wheel    512  9 Jul 21:26 dev
drwxr-xr-x  27 root     wheel     67 13 Apr 12:23 etc
drwxr-xr-x  21 root     wheel    379 13 Apr 12:23 lib
drwxr-xr-x  13 root     wheel    387 13 Apr 12:23 lib64
dr-xr-xr-x   2 root     djwilcox 128  9 Jul 21:26 opt
dr-xr-xr-x   1 root     wheel      0  9 Jul 21:46 proc
dr-xr-xr-x   1 root     wheel      0  9 Jul 21:46 sys
drwxr-xr-x   8 root     wheel      9 13 Apr 12:23 usr

I have the Firefox violentmonkey addon installed
and the eme logger script which detects drm content on the page



In this screenshot you can see Firefox playing the drm content
and the violentmonkey plugin showing the eme logger script

if you look at the eme logger window you will see it says
"Disable Widevine"

So it looks like when chromium is playing drm content
and the .fcdm-jail is active, then firefox suddenly worked

really weird



firefox-widevine.png
 
Thanks for the detailed post.

If I understand correctly, the port, linux-widevine-cdm, does not work out of the box, there are additional steps that are required, correct? If so, is it possible to make the changes to the port, auto-detect the installed browsers and setup each properly?

Is there some reason that this port does not have a package built?
 
hi mate

the port works with chromium perfectly,
from memory i think chromium may have had some work done to work with widevine ( i could be wrong on that )

the widevine package isnt going to have any work to get it working with firefox ( again from memory i think thats what the dev said )

it was just a glitch that i got firefox to play drm video once,
and i cant reproduce it

also i think firefox may be limited to 720p playing drm videos anyway

the reason there is not package is due to licensing issues

heres a tutorial on building the port with poudriere to use with chromium

 
Cool - I will have to try that out as I use chromium daily. Okay, it appears I don't need to rebuild chromium, so I will just install that port without using poudriere.
 
Cool - I will have to try that out as I use chromium daily. Okay, it appears I don't need to rebuild chromium, so I will just install that port without using poudriere.
hi mate you dont need to rebuild chromium

you just need to build the linux-widevine-cdm port
i would use poudrire to build the port if you are using packages

as its not a good idea to mix packages and ports

after you have set up poudriere it only takes a few minutes to build the package
then you just install the package and thats it job done
 
I just restarted chromium, but am still unable to play DRM videos according to a DRM test site: https://bitmovin.com/demos/drm. I will see what I'm missing. I have chromium installed from packages and just widevine from ports and launch it via the 'chrome' command. I completely stopped all chromium instances and restarted before testing.
 
I just restarted chromium, but am still unable to play DRM videos according to a DRM test site: https://bitmovin.com/demos/drm. I will see what I'm missing. I have chromium installed from packages and just widevine from ports and launch it via the 'chrome' command. I completely stopped all chromium instances and restarted before testing.
hi mate

so do you have linux-widevine-cdm installed as well as chromium
there isnt any configuration you need to do

i cant remember if you need linux enabled as well
in rc.conf

Code:
/etc/rc.conf

Code:
kld_list="linux linux64"
linux_enable="YES"

thats a shortened version of my kld_list i have omitted the drivers for nvidia
( so as not to confuse you )


20240823_14h34m34s_grim.png
 
Yes, I already have linux64 loaded for something else.

I wonder if my configuration might be doing it, I will nuke my profile and see if that helps.

EDIT: I just tried renaming my profile, ~/.config/chromium to ~/.config/chromium.bak, restarted chrome, but still no DRM support :(.
 
what version of freebsd are you running

the linux-widevine-cdm port uses the XDG_RUNTIME_DIR directory
for the fcdm-jail and fcdm-lock directories

on Freebsd 14.3 the XDG_RUNTIME_DIR is automatically created and exported
so you dont need to create the directory or set it in your shell config
the location is

Code:
/var/run/xdg/username

where username is your username

Code:
printenv

Code:
XDG_RUNTIME_DIR=/var/run/xdg/djwilcox

Code:
Yes Master ? su
Password:
# ls -l /var/run/xdg/djwilcox/
total 7
dr-xr-xr-x  11 djwilcox djwilcox 704 23 Aug 14:53 .fcdm-jail
-r--r--r--   1 djwilcox djwilcox   0 23 Aug 14:34 .fcdm-lock
srwxr-xr-x   1 djwilcox djwilcox   0 23 Aug 13:11 Alacritty-wayland-0-27062.sock
drwx------   2 djwilcox djwilcox   3 23 Aug 13:12 at-spi
drwx------   3 djwilcox djwilcox   3 23 Aug 13:11 dbus-1
drwx------   2 djwilcox djwilcox   3 23 Aug 14:38 dconf
drwx------   2 djwilcox djwilcox   2 23 Aug 13:12 doc
drwx------   2 djwilcox djwilcox   3 23 Aug 13:11 dwlb
drwx------   2 djwilcox djwilcox   3 23 Aug 13:12 emacs
drwx------   2 djwilcox djwilcox   2 23 Aug 14:34 pulse
-rw-------   1 djwilcox djwilcox   0 23 Aug 13:12 tofi.lock
srwxr-xr-x   1 djwilcox djwilcox   0 23 Aug 13:11 wayland-0
-rw-r-----   1 djwilcox djwilcox   0 23 Aug 13:11 wayland-0.lock
-rwx------   1 root     djwilcox   0 23 Aug 13:11 xdg_session.0

what does printenv show for the location of XDG_RUNTIME_DIR
 
when you try a play a drm video with chromium does the XDG_RUNTIME_DIR
contain the following directories

Code:
dr-xr-xr-x  11 djwilcox djwilcox 704 23 Aug 14:53 .fcdm-jail
-r--r--r--   1 djwilcox djwilcox   0 23 Aug 14:34 .fcdm-lock
 
the fcdm-jail directory is actually a small linux jail

when chromium is playing a drm video
running doas jls lists the jail

Code:
Yes Master ? doas jls
   JID  IP Address      Hostname                      Path
     4                                                /var/run/xdg/djwilcox/.fcdm-jail
 
chromium installed as a pkg

Code:
pkg info chromium

the chromium package is built with widevine off

Code:
WIDEVINE       : off

but that doesnt matter
once you install the linux-widevine-cdm port or package built with poudriere it works

very odd that its not working for you
 
Strange, the odd thing is that I now have audio working in chromium while using citrix workspace so I suspect something is working.
 
thats odd

i wonder if its a missing codec issue
but the fcdm-jail isnt created when trying to play a video

i dont know if the jail wouldnt start because of a missing codec
or if the issue is something else

heres my prime list of installed packages


pkg info


root dotfiles


dotfiles

 
Back
Top