Allow definition of MediaRecorder mimeType #1708
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new option for the
@uppy/webcam
plugin calledpreferredMimeType
which defaults asnull
.If a value is passed, the browser's
MediaRecorder
implementation checks if thepreferredMimeType
is supported, and if it thinks it is, will attempt to record using thepreferredMimeType
rather than the browser default.If the
preferredMimeType
is unsupported, the browser will fall back to using its default recording mime type.This allows, for example, a user to pass
preferredMimeType: "video/webm"
during the@uppy/webcam
plugin construction which will instruct the browser to record to a.webm
container.Specific codecs may also be passed here. For example,
video/webm;codecs=vp8
may still parse as valid by the browser.Limitations
This does not currently change the mime type for captured images on line 282 (
image/jpeg
) and will only pass thepreferredMimeType
to the browserMediaRecorder
API.Reference
https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/MediaRecorder
https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/isTypeSupported
https://cs.chromium.org/chromium/src/third_party/blink/web_tests/fast/mediarecorder/MediaRecorder-isTypeSupported.html?q=MediaRecorder-isTypeSupported&dr
https://www.webmproject.org/about/faq/