-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Get user media constraints resizemode #41153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Get user media constraints resizemode #41153
Conversation
Preview URLs
External URLs (1)URL:
|
The **`MediaTrackConstraints`** dictionary is used to describe a set of capabilities and the value or values each can take on. A constraints dictionary is passed into {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}} to allow a script to establish a set of exact (required) values or ranges and/or preferred values or ranges of values for the track, and the most recently-requested set of custom constraints can be retrieved by calling {{domxref("MediaStreamTrack.getConstraints", "getConstraints()")}}. | ||
The **`MediaTrackConstraints`** dictionary is used to describe a set of media capabilities and the value or values each can take on. | ||
|
||
A constraints dictionary is passed into the {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}} method of the {{domxref("MediaStreamTrack")}} interface to allow a script to establish a set of exact (required) values or ranges and/or preferred values or ranges of values for the track, and the most recently-requested set of custom constraints can be retrieved by calling {{domxref("MediaStreamTrack.getConstraints", "getConstraints()")}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A constraints dictionary is passed into the {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}} method of the {{domxref("MediaStreamTrack")}} interface to allow a script to establish a set of exact (required) values or ranges and/or preferred values or ranges of values for the track, and the most recently-requested set of custom constraints can be retrieved by calling {{domxref("MediaStreamTrack.getConstraints", "getConstraints()")}}. | |
A constraints dictionary is passed into the {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}} method of the {{domxref("MediaStreamTrack")}} interface to allow a script to establish a set of exact (required) values or ranges and/or preferred values or ranges of values for the track. | |
The most recently-requested set of custom constraints can be retrieved by calling {{domxref("MediaStreamTrack.getConstraints", "getConstraints()")}}. |
|
||
A constraints dictionary is passed into the {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}} method of the {{domxref("MediaStreamTrack")}} interface to allow a script to establish a set of exact (required) values or ranges and/or preferred values or ranges of values for the track, and the most recently-requested set of custom constraints can be retrieved by calling {{domxref("MediaStreamTrack.getConstraints", "getConstraints()")}}. | ||
|
||
Objects of this type may also be passed to the {{domxref("MediaDevices/getUserMedia","getUserMedia()")}} and {{domxref("MediaDevices/getDisplayMedia","getDisplayMedia()")}} methods of the {{domxref("MediaDevices")}} interface in order to specify constraints on a media stream requested from hardware such as a camera or microphone, and from a screen or window capture, respectively. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Objects of this type may also be passed to the {{domxref("MediaDevices/getUserMedia","getUserMedia()")}} and {{domxref("MediaDevices/getDisplayMedia","getDisplayMedia()")}} methods of the {{domxref("MediaDevices")}} interface in order to specify constraints on a media stream requested from hardware such as a camera or microphone, and from a screen or window capture, respectively. | |
Objects of this type may also be passed to: | |
- The {{domxref("MediaDevices.getUserMedia()")}} method, to specify constraints on a media stream requested from hardware such as a camera or microphone. | |
- The {{domxref("MediaDevices.getDisplayMedia()")}} method, to specify constraints on a media stream requested from a screen or window capture. |
}); | ||
``` | ||
|
||
The browser may return another resolutions if an exact match is not available and the source is not to be scaled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The browser may return another resolutions if an exact match is not available and the source is not to be scaled. | |
The browser may return another resolution if an exact match is not available and the source is not to be scaled. |
resolutions if an exact match is not available, or the user overrides it. | ||
The browser will try to honor the constraints, and will return a matching track if supported by the underlying hardware. | ||
If not supported, the browser may attempt to crop and downscale a higher resolution stream from the underlying hardware in order to match the constraint. | ||
This will commonly be the default behavior, but can be forced by setting the [`resizeMode`](/en-US/docs/Web/API/MediaTrackConstraints#resizemode) constraint to `crop-and-scale` (or disabled with `none`): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will commonly be the default behavior, but can be forced by setting the [`resizeMode`](/en-US/docs/Web/API/MediaTrackConstraints#resizemode) constraint to `crop-and-scale` (or disabled with `none`): | |
This will commonly be the default behavior, but can be forced by setting the [`resizeMode`](/en-US/docs/Web/API/MediaTrackConstraints#resizemode) constraint to `crop-and-scale` (or disabled by setting it to `none`): |
FF144 added a new constraint parameter
resizeMode
for use withMediaDevices.getUserMedia()
andgetDisplayMedia()
.This allows a developer to specify whether the video from the camera should be cropped and/or downscaled to match other constraints, which may be natively supported by the camera - essentially gives them what they ask for rather than what the camera is capable of delivering. It also allows them to specify that it doesn't want scaling.
This updates the relevant docs (First two commits are layout only).
The main changes are to:
MediaTrackConstraints
which is where the constraint is documented to make it clear that it is also used in these methods (not just some others).Related docs work can be tracked in #41132