我在最新版的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
我接着编译了一组长度为5的数据段——数据块已经准备好了。但是当我为每个数据段创建URL时:
URL.createObjectURL(videoSegment)
只有第一个视频可以播放。为什么会这样呢?
更新
如果我在onDataAvailable
中停止/启动录制器,则会得到可播放的片段,这些片段由于我在处理视频后立即调用停止而与来自onDataAvailable的不可播放的小片段分开。通过这种方式,我可以“近似”所需的行为,然后忽略小于某个阈值的blob以忽略“死区”片段。虽然这听起来很奇怪,但如果可能的话,我想让正确的分割工作起来。