Video recording for Safari Browser

自古美人都是妖i 提交于 2020-07-07 10:21:53

问题


In my sample ReactJs application I am using react-multimedia-capture - which uses navigator.mediaDevices.getUserMedia and the MediaRecorder API to record video.

I am able to record video from Chrome, but in Safari I am unable to capture the video. The error is something like

MediaRecorder is not defined.

Could someone please help me out like:
Does Safari supports basic video capturing?


回答1:


Safari is currently not supporting MediaRecorder API by default, but you can enable them from Develop > Experimental Features > MediaRecorder.

The way to record video from safari is to use peer to peer connection and capture video at the other end. There are few open-source application and third-party services which offer this and they are quite stable.

If you are only going to support recording from mobile, you can use HTML5 file API, which will pop up the camera in a single click. you can trim it for specific duration using ffmpeg or azure media services.

<input id="videoFile" type="file" class="hidden" accept="video/*" capture="">

Just make sure to save this file as .mp4 with the use of JavaScript to make it playable across every device or with <video> tag.

var file = $('#videoFile')[0]; var blob = file.files[0].slice(0, file.files[0].size, 'video/mp4'); var newFile = new File([blob], 'video.mp4', { type: 'video/mp4' });




回答2:


A basic implementation of MediaStream Recorder API has just been introduced in Safari Technology Preview 73 on macOS (Jan 2019).

I've covered supported/unsupported features in this article.

Hopefully, a more complete implementation will make it's way soon to Safari 12.x on macOS and iOS.




回答3:


Octavian Naicu

A basic implementation of MediaStream Recorder API has just been introduced in Safari Technology Preview 73 on macOS (Jan 2019).

Did you try video recording on Safari IOS 12.2?

Why does upload image via camera work on mobile-safari but not as iOS PWA?



来源:https://stackoverflow.com/questions/54344342/video-recording-for-safari-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!