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

感情迁移 提交于 2019-12-23 07:32:03

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/45221112/recording-cross-platform-h-264-videos-using-webrtc-mediarecorder

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