【问题标题】:rtcmulticonnection: webrtc recordrtc not returning a blobrtcmulticonnection:webrtc recordrtc 不返回 blob
【发布时间】:2016-07-15 11:51:37
【问题描述】:

我正在尝试使用我认为的标准示例来简单地录制 webrtc 视频。图书馆在这里:https://github.com/muaz-khan/RTCMultiConnection

rtcMultiConnection.onstream = function(e) {
  var mediaElement = getMediaElement(e.mediaElement, {
        onRecordingStarted: function(type) {
            // www.RTCMultiConnection.org/docs/startRecording/
            rtcMultiConnection.streams[e.streamid].startRecording();
        },
        onRecordingStopped: function(type) {
            // www.RTCMultiConnection.org/docs/stopRecording/
            rtcMultiConnection.streams[e.streamid].stopRecording(function(blob){
              console.log("test");
              console.log(blob);
            });
        }});}

我可以按照函数调用的步骤进行操作,问题是回调永远不会从 recordrtc.js 运行......

转到https://github.com/muaz-khan/RecordRTC/blob/master/RecordRTC.js的第100行

它运行:

mediaRecorder.stop(_callback);

从不调用回调......

即使直接调用函数也不行:

        console.log(rtcMultiConnection.streams[e.streamid].audioRecorder.getBlob());
        console.log(rtcMultiConnection.streams[e.streamid].videoRecorder.save("a.png"));

我想知道 recordrtc 和 rtcmulticonneciton 的两个不同版本是否正在交互......有什么想法吗?也许是旧的recordrtc,但我找不到旧版本

【问题讨论】:

    标签: webrtc


    【解决方案1】:

    请使用blob.video:

    var stream = connection.streams['stream-id'];
    stream.stopRecording(function(blob) {
        var h2;
        if (blob.audio) {
            h2 = document.createElement('h2');
            h2.innerHTML = '<a href="' + URL.createObjectURL(blob.audio) + '" target="_blank">Open recorded ' + blob.audio.type + '</a>';
            div.appendChild(h2);
        }
        if (blob.video) {
            h2 = document.createElement('h2');
            h2.innerHTML = '<a href="' + URL.createObjectURL(blob.video) + '" target="_blank">Open recorded ' + blob.video.type + '</a>';
            div.appendChild(h2);
        }
    });
    

    2016 年 3 月 29 日更新

    这是实际的文档:

    请确保:

    1. 您使用的是 v2.2.2
    2. 你先打电话给startRecording

    对于 v3,您可以直接使用 RecordRTC:

    connection.onstream = function(event) {
        recordStream(event.stream);
    };
    
    function recordStream(stream) {
        if (!!window.recorder) return;
        window.recorder = RecordRTC(stream, {
            type: 'video'
        });
        recorder.startRecording();
    }
    
    btnStopRecording.onclick = function() {
        if (!window.recorder) return;
        recorder.stopRecording(function() {
            var blob = recorder.blob;
    
            // or dataURL
            recorder.getDataURL(func_callback);
        });
    };
    
    btnStartRecording.onclick = function() {
        var stream = connection.attachStreams[0];
        recordStream(straem);
    
        // or
        var stream = connection.streamEvents['stream-id'].stream;
        recordStream(straem);
    };
    

    sn-p 以上也可以在 v2.2.2 中使用。

    【讨论】:

    • 很遗憾,这个函数根本没有被调用,不管是blob.video还是没有...没有写入日志
    • 使用RecordRTC的新版本现在可以使用了。您可能想检查一些记录在案的代码,因为我上面的代码确实曾经工作过。我猜测预期的流已经改变或者在 recordrtc.无论哪种方式,它现在都有效。谢谢!
    猜你喜欢
    • 2022-01-11
    • 2013-06-06
    • 1970-01-01
    • 2013-02-26
    • 1970-01-01
    • 2016-12-13
    • 2021-11-07
    • 2011-09-13
    • 2012-05-29
    相关资源
    最近更新 更多