Blob video duration metadata [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-03 02:22:32
Kaiido

This question is an almost duplicate of this other one. (But since there is a bounty on it, we can't vote to close)

This is a known chrome bug.

You can have this duration from the browser itself by loading the video, setting its currentTime to some extra-value, then reading the duration, but you won't have it attached to the file itself, at least not until the bug has been fixed.

Until the chrome bug that Kaiido mentioned gets fixed, this worked for me:

while(video.duration === Infinity) {
  await new Promise(r => setTimeout(r, 1000));
  video.currentTime = 10000000*Math.random();
}
let duration = video.duration;

It would probably be a better idea to listen for the "durationchange" event though, rather than having the arbitrary 1 second pauses.

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