简体   繁体   English

NodeJS - 寻找更快的方法来创建FFMPEG缩略图

[英]NodeJS - Looking for faster ways to create FFMPEG thumbnails

I am using fluent-ffmpeg and ffmpeg in node: 我在节点中使用fluent-ffmpeg和ffmpeg:

var ffmpeg = require('fluent-ffmpeg');
var src = "http://upload.wikimedia.org/wikipedia/commons/7/79/Big_Buck_Bunny_small.ogv";
ffmpeg(src)
.on('filenames', function(filenames) {
    console.log('Will generate ' + filenames.join(', ') + ' into tempfiles.')
})
.on('end', function() {
    console.log('1 Screenshot successfully taken');

})
.on('error', function(err, stdout, stderr) {
console.log("ffmpeg stdout:\n" + stdout);
console.log("ffmpeg stderr:\n" + stderr);
})
.screenshots({
    filename: randomResult,
    timemarks: [520.929831],
    folder: '/'
});

Usually, it takes 2-3 seconds to take one thumbnail. 通常,拍摄一个缩略图需要2-3秒。 I need it to be 0.5-1 seconds for real-time development. 对于实时开发,我需要0.5-1秒。 I mean, what is the problem here - downloading a single png file on my computer takes way below 2-3 seconds to complete, why is ffmpeg lagging so much? 我的意思是,这里的问题是什么 - 在我的计算机上下载一个png文件需要2-3秒才能完成,为什么ffmpeg会滞后这么多? something just doesn't seem right. 事情似乎并不合适。

Per the fluent-ffmpeg docs "It will not work on input streams." 根据fluent-ffmpeg 文档 “它不适用于输入流。” so I suspect the entire file is trying to load. 所以我怀疑整个文件正在尝试加载。

You could try running ffmpeg as a child process directly using the -ss switch as explained in this post . 你可以尝试直接使用-ss开关在此解释运行的ffmpeg作为一个子进程 This should bump your performance. 这应该会影响你的表现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM