librewolf/issues
25
145

allow capturing restricted video (captureStream API is disabled for DRM with Widevine / EME) #2650

Closed
opened 2025年08月26日 02:18:44 +02:00 by obunga · 3 comments

(mostly lifted from https://github.com/BrowserWorks/Waterfox/issues/1895, since the Waterfox developers refused to implement this with no real explanation. 5th most 👍'd issue by the way)

DESCRIBE THE BUG
It is not possible to capture / record a restricted video because it is disabled in the official Firefox source code (captureStream API is disabled for DRM with Widevine / EME). The restriction / censorship source code seems to be currently located at line 4075 in the function HTMLMediaElement::CanBeCaptured of the file https://searchfox.org/firefox-main/source/dom/media/mediaelement/HTMLMediaElement.cpp#4075:

 // Prevent capturing restricted video
 if (aCaptureType == StreamCaptureType::CAPTURE_ALL_TRACKS &&
 ContainsRestrictedContent()) {
 return false;
 }
 return true;

Removing the if code block and recompiling should fix the issue.

Chromium has a similar restriction here ("Avoid capturing from EME-protected Media Elements" / "Stream capture not supported with EME"): https://chromium.googlesource.com/chromium/src/third_party/+/master/blink/renderer/modules/mediacapturefromelement/html_media_element_capture.cc#303

TO REPRODUCE

  1. With Widevine DRM enabled, go to https://bitmovin.com/demos/drm to test a DRM demo video.
  2. Play the video.
  3. Open the web console (Ctrl+Shift+K shortcut).
  4. Paste a JavaScript code using captureStream API to record a video, like the one on https://gist.github.com/lthrhx/610e94b03bed193f4a2e486baf20e477 and let the video end to trigger the file saving.
    You can also just use the following test code which will produce an error with the name NS_ERROR_FAILURE if there is a restriction:
var video = document.getElementsByTagName("video")[0];
var stream = video.captureStream ? video.captureStream() : video.mozCaptureStream();

The code will not produce an error in the demo page when "Play DRM-controlled content" is OFF.

Since LibreWolf is designed with user freedom in mind, it should not prevent capturing restricted video. Like it could be done if people would customize and compile the Firefox source code.

_(mostly lifted from <https://github.com/BrowserWorks/Waterfox/issues/1895>, since the Waterfox developers refused to implement this with no real explanation. 5th most 👍'd issue by the way)_ ​ **DESCRIBE THE BUG** It is not possible to capture / record a restricted video because it is disabled in the official Firefox source code (captureStream API is disabled for DRM with Widevine / EME). The restriction / censorship source code seems to be currently located at line 4075 in the function `HTMLMediaElement::CanBeCaptured` of the file <https://searchfox.org/firefox-main/source/dom/media/mediaelement/HTMLMediaElement.cpp#4075>: ```cpp // Prevent capturing restricted video if (aCaptureType == StreamCaptureType::CAPTURE_ALL_TRACKS && ContainsRestrictedContent()) { return false; } return true; ``` Removing the `if` code block and recompiling should fix the issue. Chromium has a similar restriction here ("Avoid capturing from EME-protected Media Elements" / "Stream capture not supported with EME"): https://chromium.googlesource.com/chromium/src/third_party/+/master/blink/renderer/modules/mediacapturefromelement/html_media_element_capture.cc#303 **TO REPRODUCE** 1. With Widevine DRM enabled, go to https://bitmovin.com/demos/drm to test a DRM demo video. 2. Play the video. 3. Open the web console (Ctrl+Shift+K shortcut). 4. Paste a JavaScript code using captureStream API to record a video, like the one on https://gist.github.com/lthrhx/610e94b03bed193f4a2e486baf20e477 and let the video end to trigger the file saving. You can also just use the following test code which will produce an error with the name `NS_ERROR_FAILURE` if there is a restriction: ```js var video = document.getElementsByTagName("video")[0]; var stream = video.captureStream ? video.captureStream() : video.mozCaptureStream(); ``` The code will not produce an error in the demo page when "Play DRM-controlled content" is OFF. Since LibreWolf is designed with user freedom in mind, it should not prevent capturing restricted video. Like it could be done if people would customize and compile the Firefox source code.

We can't just remove that if. This would be against the web spec and (more importantly) would be fingerprintable by websites. One would need to come up with some reliably way to only allow recording in user approved scripts which seems rather difficult to me. Is there any reason to not do a screen recording of a full screen or kios mode librewolf window?

Ref https://bugzilla.mozilla.org/show_bug.cgi?id=1071482

We can't just remove that `if`. This would be against the web spec and (more importantly) would be fingerprintable by websites. One would need to come up with some reliably way to only allow recording in user approved scripts which seems rather difficult to me. Is there any reason to not do a screen recording of a full screen or kios mode librewolf window? Ref https://bugzilla.mozilla.org/show_bug.cgi?id=1071482
Author
Copy link

Is there any reason to not do a screen recording of a full screen

This type of browser recording is able to cleverly auto-detect width/height/framerate, that's one reason.
Meaning that if the video being played is, say, 1440x1080@120FPS, it will record at 1440x1080@120FPS with no further setup (not losslessly though, it's still not a proper "rip") , even if your monitor supports a maximum of 1280x720@60FPS.

The web spec reasoning seems kinda flimsy to me, it's clear that no one except some mega corpos wanted video DRM to become a web standard in the first place. Mozilla added support reluctantly with an ON/OFF toggle, so if we can add another small way to "weaken" it, I'm all for it.

I don't know about the fingerprinting part, there are so many ways to abuse it that I feel Tor is the one and only valid prevention...

> Is there any reason to not do a screen recording of a full screen This type of browser recording is able to cleverly auto-detect width/height/framerate, that's one reason. Meaning that if the video being played is, say, `1440x1080@120FPS`, it will record at `1440x1080@120FPS` with no further setup (not losslessly though, it's still not a proper "rip") , even if your monitor supports a maximum of `1280x720@60FPS`. The web spec reasoning seems kinda flimsy to me, it's clear that no one except some mega corpos wanted video DRM to become a web standard in the first place. Mozilla added support [reluctantly](<https://blog.mozilla.org/en/mozilla/drm-and-the-challenge-of-serving-users/>) with an ON/OFF toggle, so if we can add another small way to "weaken" it, I'm all for it. I don't know about the fingerprinting part, there are so many ways to abuse it that I feel Tor is the one and only valid prevention...

Removing this would be plain illegal.
No matter how ineffective this measure is, removing it would count as "bypassing copy protection", which is illegal in many countries.

Removing this would be plain illegal. No matter how ineffective this measure is, removing it would count as "bypassing copy protection", which is illegal in many countries.
alyx161 2026年03月08日 14:08:38 +01:00
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Labels
Clear labels
Branding
Issues that relate to our logo or the branding of our browser and website.
Broken Upstream
Issue is also present in Firefox
Build
Alpine
Issues specific to the Alpine Linux build of LibreWolf.
Build
AppImage
Issues specific to the AppImage release of LibreWolf.
Build
AUR
Issues specific to the AUR build of LibreWolf.
Build
Debian
Issues specific to our official release for Debian based distros.
Build
DebianOBS
Issues specific to the non-official OBS build of LibreWolf.
Build
Fedora
Issues specific to our official release for Fedora.
Build
FedoraCOPR
Issues specific to the non-official COPR build of LibreWolf.
Build
Flatpak
Issues specific to the Flatpak release of LibreWolf.
Build
Gentoo
Issues specific to the Gentoo build of LibreWolf.
Component: Infrastructure
Issues related to infrastructure provided by LibreWolf
Component
Builds
Issues related to how we build LibreWolf
Component
Patches
Issue with one of the patches in our source code.
Component
Settings
Issues related to the settings of LibreWolf.
Component
UI
A purely cosmetic issue in our browser.
Component
Website
Issues with our website.
Docs
Change required
A needed change in our documentation.
Docs
FYI
Issues that document a change, or how stuff gets patched, built or configured.
Flag
Caution
Change that might be tricky or that needs to be carefully evaluated. Best suited for core members.
Flag
Good first issue
Suited for a first contribution as it is a straightfoward task!
FreeBSD
Issues related to the FreeBSD release of LibreWolf.
Linux
Issues realted to one or all our Linux releases.
macOS
Issues realated to the MacOS release of LibreWolf.
Needed
Help
We are stuck :-(
Needed
Info
Closing in ten days if no details are provided.
Needed
Testing
We are almost there!
Prio
High
Issues with a high priority
Prio
Low
Prio
Normal
Prio/Urgent
Issues needing immediate attention
Repositories
An issue with our repositories.
Research
Collecting informations to document something or to evaluate a change.
Source
Issues related to the source code of LibreWolf.
Status
Blocked
An issue blocked by another one.
Status
Duplicate
Look for existing issues.
Status
Icebox
Change that is not happening soon or issue that cannot be tested.
Status
Known issue
An issue that we are aware of but that we cannot fix at the moment.
Status
Not Planned
The requested feature is currently not planned
Status
Upstream
Either we upstreamed the issue or a fix is coming directly from Mozilla!
Status
Won't fix
Does not require a fix.
Type
?
What?
Type
Bug
Ouch...
Type
Discussion
Let's have a talk...
Type
Feature
A feature request.
Type
Question
Not a issue but just a user question
Type
Task
This needs to be done
Windows
Issues related to the Windows release of Librewolf.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
librewolf/issues#2650
Reference in a new issue
librewolf/issues
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?