简体   繁体   中英

NodeJS - Looking for faster ways to create FFMPEG thumbnails

I am using fluent-ffmpeg and ffmpeg in node:

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. I need it to be 0.5-1 seconds for real-time development. 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? something just doesn't seem right.

Per the fluent-ffmpeg docs "It will not work on input streams." 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 . This should bump your performance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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