Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video recording for Safari Browser

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?

like image 837
Sravan Shetty Avatar asked Jan 24 '19 10:01

Sravan Shetty


People also ask

Does Safari support video recording?

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.

How do I enable recording on Safari?

On your Mac, choose Apple menu > System Preferences, click Security & Privacy , then click Privacy. Select Screen Recording. Select the checkbox next to an app to allow it to record your screen.


2 Answers

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' });

like image 141
Kishan Patel Avatar answered Sep 26 '22 11:09

Kishan Patel


In latest Safari you can enable MediaRecorder from Develop menu.

Try this Cam Recorder HTML5 demo that also provides detailed instructions for Safari.

like image 43
TopReseller Avatar answered Sep 25 '22 11:09

TopReseller