Skip to content
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

Allow definition of MediaRecorder mimeType #1708

Merged
merged 7 commits into from Jul 8, 2019

Conversation

davekiss
Copy link
Contributor

@davekiss davekiss commented Jul 3, 2019

This PR introduces a new option for the @uppy/webcam plugin called preferredMimeType which defaults as null.

If a value is passed, the browser's MediaRecorder implementation checks if the preferredMimeType is supported, and if it thinks it is, will attempt to record using the preferredMimeType 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 the preferredMimeType to the browser MediaRecorder 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/

This PR introduces a new option for the `@uppy/webcam` plugin called `preferredMimeType` which defaults as `null`.

If a value is passed, the browser's `MediaRecorder` implementation checks if the `preferredMimeType` is supported, and if it thinks it is, will attempt to record using the `preferredMimeType` 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 the `preferredMimeType` to the browser `MediaRecorder` 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/
@arturi
Copy link
Contributor

arturi commented Jul 5, 2019

Very nice! Thanks for the PR, we’ll try to review as soon as we can.

Copy link
Contributor

@goto-bus-stop goto-bus-stop left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@goto-bus-stop goto-bus-stop merged commit d5b45a8 into transloadit:master Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants