【发布时间】:2021-06-26 02:58:34
【问题描述】:
媒体源扩展中的 WebM 有一个奇怪的问题。
视频时长(根据videoEl.duration)为8.354999999999999。
视频到达当前时间 = 8.328015 并停止,没有触发任何事件。
MediaSource 持续时间为 8.403,我可以看到,当它完成时没有触发任何事件。
我找不到视频文件有任何问题。我的代码是相当标准的附加到缓冲区,它可以与其他 WebM 一起使用。
这是我的代码(在 Redux Saga 中)
while(chunks.length && !complete){
const event = yield take(sourceBufferEvents)
console.log(event)
if(event.type === "updateend"){
if(loading){
yield fork(loaded, true)
while(loading){
const event = yield take(videoEvents)
if(chunks && event.type === "playing"){
loading = false
yield fetchNextSegment(asset.id, asset.remoteUrl, sourceBuffer, chunks.shift())
videoEvents.close()
}
}
}
else {
yield fetchNextSegment(asset.id, asset.remoteUrl, sourceBuffer, chunks.shift() )
index ++;
}
}
if(total === index){
// yield mediaSource.endOfStream()
// complete = true
while(sourceBuffer.updating){
console.log(total, index)
}
console.log(sourceBuffer.updating)
}
}
这些事件在 updateEnd 时被调用。
sourceBuffer.updating 永远不会错误
我收到DOMException: Failed to execute 'endOfStream' on 'MediaSource': The 'updating' attribute is true on one or more of this MediaSource's SourceBuffers.
当我尝试结束直播时
【问题讨论】:
-
显示你的代码,你调用 endOfStream() 吗?
-
@beek “我的代码可以与其他 WebM 一起使用...我找不到视频文件有任何问题。” 如果其他文件可以正常工作,那么我仍然会怀疑某些问题那个特定的 webM 是错误的。如果重新编码文件会发生什么?各种媒体播放器是否都提供一致的持续时间(例如: 浏览器时间 vs VLC 时间 vs FFplay 时间)?
-
@Kaiido 不,我没有。会看的谢谢。
标签: javascript html5-video webm media-source