【发布时间】:2017-05-30 13:53:30
【问题描述】:
我在最新的 chrome 上有以下内容:
var options = { mimeType: "video/webm;codecs=vp8" };
internalMediaRecorder = new MediaRecorder(internalStream, options);
internalMediaRecorder.ondataavailable = function (blob) {
// put blob.data into an array
var src = URL.createObjectURL(blobData.segment);
const $container = $("body");
const $video = $("<video id='" + blobData.ts + "-" + blob.data.size + "' controls src='" + src + "'></video>").css("max-width", "100%");
$container.prepend($video);
// if I stop/start the recorder, I get playable segments here, separated by unplayable mini-segments from onDataAvailable because I call stop right after processing a video. I can "approximate" desired behavior by doing this and then ignoring blobs that are less than some threshhold to ignore the "dead gap" segments.
}
internalMediaRecorder.start(segmentLengthInMs); // every 5s
然后我编译一个 5s 段的数组 - blob 数据可用。但是,当我为这些段中的每一个创建一个 URL 时:
URL.createObjectURL(videoSegment)
仅播放第一个视频。这是为什么呢?
更新
如果我在onDataAvailable 中停止/启动录像机,我会在此处获得可播放片段,由 onDataAvailable 中的不可播放迷你片段分隔,因为我在处理视频后立即调用停止。我可以通过这样做来“近似”期望的行为,然后忽略小于某个阈值的 blob 以忽略“死间隙”段。不过,这闻起来像脚,如果可能的话,我希望进行适当的分割。
【问题讨论】:
-
当您对 dataAvailable 事件执行启动/停止方法时,您是否遇到任何性能问题(滞后/崩溃)?我目前正在使用相同的方法来获取单独的可播放片段,但似乎这种方法会使 Chrome 在几次通过后崩溃
标签: html google-chrome webrtc getusermedia web-mediarecorder