javascript 如何创建视频文件的blob
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26533691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create blob of a video file
提问by MindBrain
I would like to create a Blob of a local video file file:///home/user/NodeJS/Projects/project1/routes/../videosTrans/Node.js tutorial for beginners - an introduction to Node.js with Express2.js.mp4
我想为初学者创建一个本地视频文件 file:///home/user/NodeJS/Projects/project1/routes/../videosTrans/Node.js 教程的 Blob - Node.js 与 Express2 的介绍。 js.mp4
I could not understand the exact format of the Blob. I wish to create it to give it as input to the function createObjectURL(). The following does not work:
我无法理解 Blob 的确切格式。我希望创建它以将其作为函数 createObjectURL() 的输入。以下不起作用:
var URL = this.window.URL || this.window.webkitURL;
var file = new Blob(["file:///home/sanika/NodeJS/Projects/project1/routes/../videosTrans/Node.js tutorial for beginners - an introduction to Node.js with Express2.js.mp4"], "type" : "video\/mp4");
var value = URL.createObjectURL(file);
回答by Muhammad Babar
Please use the second parameter of blob as object. so your code should be :
请使用 blob 的第二个参数作为对象。所以你的代码应该是:
var URL = this.window.URL || this.window.webkitURL;
var file = new Blob(
["file:///home/sanika/NodeJS/Projects/project1/routes/../videosTrans/Node.js tutorial for beginners - an introduction to Node.js with Express2.js.mp4"],
{"type" : "video\/mp4"});
var value = URL.createObjectURL(file);