Blob video duration metadata [duplicate]

廉价感情. 提交于 2019-12-03 11:56:20

问题


I am writing a software that manipulates camera stream video in firefox.

I am generating a Blob with video type recorded with MediaRecorder API.

What i am doing to save the blob as video in local storage is using FileSaver library :

    FileSaver.saveAs(BlobVideo,"video.mp4");

It seems the video doesnt have any max duration, so i cannot navigate in timeline in my newly generated video in VLC, for example.

Is there a way to set duration metadatas on a blob video?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/38062864/blob-video-duration-metadata

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