Skip to content

Conversation

hamishwillee
Copy link
Collaborator

FF144 added a new constraint parameter resizeMode for use with MediaDevices.getUserMedia() and getDisplayMedia().

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:

  • Better cross-link MediaTrackConstraints which is where the constraint is documented to make it clear that it is also used in these methods (not just some others).
  • Provide an example explaining the downscaling.

Related docs work can be tracked in #41132

@hamishwillee hamishwillee requested a review from a team as a code owner September 16, 2025 05:59
@hamishwillee hamishwillee requested review from wbamberg and removed request for a team September 16, 2025 05:59
@github-actions github-actions bot added Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed labels Sep 16, 2025
Copy link
Contributor

github-actions bot commented Sep 16, 2025

Preview URLs

Flaws (2)

Note! 2 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/API/MediaTrackConstraints
Title: MediaTrackConstraints
Flaw count: 2

  • unknown:
    • Error serializing baseline for numeric-seperators: missing field description``
    • Error serializing baseline for single-color-gradients: missing field description``
External URLs (2)

URL: /en-US/docs/Web/API/MediaDevices/getUserMedia
Title: MediaDevices: getUserMedia() method


URL: /en-US/docs/Web/API/MediaTrackConstraints
Title: MediaTrackConstraints

(comment last updated: 2025-09-19 01:08:22)

- `none`
- : The user agent uses the resolution provided by the underlying hardware, such as a camera or its driver, or the OS.

If `resizeMode` is unspecified the browser will choose a resolution based on a [fitness distance](https://w3c.github.io/mediacapture-main/#dfn-fitness-distance) that considers the specified constraints and _both_ of the allowed values.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wbamberg I added this line since last review to make it clear that there is no explicit default - just a calculation that works out what would be best based on the constraints with none and the constraints with crop-and-scale set.

Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thank you Hamish!

@wbamberg wbamberg merged commit b20a464 into mdn:main Sep 19, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants