Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recording cross-platform (H.264?) videos using WebRTC MediaRecorder

I have the following specified with my MediaRecorder implementation:

const getMediaRecorderOptions = function () {
    var options = { mimeType: "video/webm;codecs=vp8" }; // 9 was lagggy, cpu-intensive

    if (!MediaRecorder.isTypeSupported(options.mimeType)) {
        logger.recorderLog(options.mimeType + " is not Supported");
        options = { mimeType: "video/webm;codecs=vp8" };

        if (!MediaRecorder.isTypeSupported(options.mimeType)) {
            logger.recorderLog(options.mimeType + " is not Supported");
            options = { mimeType: "video/webm" };

            if (!MediaRecorder.isTypeSupported(options.mimeType)) {
                logger.recorderLog(options.mimeType + " is not Supported");
                options = { mimeType: "" };
            }
        }
    }
    return options;
}

Obviously, this is just for webm which isn't supported on iOS Safari or MacOS. I'm trying to avoid doubling our storage and introducing encoding complexity. Is there any way MediaRecorder on Chrome can record directly to a cross-platform container format, from any platform?

like image 464
SB2055 Avatar asked Jul 20 '17 17:07

SB2055


People also ask

What is MediaRecorder?

android.media.MediaRecorder. Used to record audio and video. The recording control is based on a simple state machine (see below).

What is MediaRecorder Iphone?

Media Recorder records both audio and video recordings and save them into many different formats of your liking with just a few simple taps! All recordings will automatically appear on the Files app.


1 Answers

You should be able to record to webm/h.264

var options = {mimeType: 'video/webm;codecs=h264'};

media_recorder = new MediaRecorder(stream, options);

So you have the right cross platform video format (H.264) in a WebM container.

Now you could try ffmpeg.js and just change the container from WebM to mp4 - coping the H.264 stream - no transcoding (-vcodec copy).

I recorded to webm/h.264 in Chrome but I didn't try re-wrapping it with ffmpeg.js.

like image 118
Markus Schumann Avatar answered Oct 21 '22 22:10

Markus Schumann