作者:nuabolalalala4_135 | 来源:互联网 | 2023-09-10 11:01
我设置了一个节点服务器,它需要一个文件进行预处理。如果仅使用ffmpeg库,则可以毫无问题地处理文件;使用fluent-ffmpeg时,如果视频为20秒,则输出将仅为视频的后半部分(10秒)。我试过多个不同长度的文件,并且存在相同的问题。知道为什么会这样吗?
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const ffprobePath = require('@ffprobe-installer/ffprobe').path;
const ffmpeg = require('fluent-ffmpeg');
...
ffmpeg.setffmpegPath(ffmpegPath);
ffmpeg.setffprobePath(ffprobePath);
ffmpeg('video.mov').videoBitrate('512k').output('./output/video.mov')
.on('error',function(err,stdout,stderr) {
console.log('Cannot process video: ' + err.message);
}).screenshots({
count: 1,size:'640x480'
});
结果我误解了文档...不能在同一调用中同时包含输入处理和屏幕截图...应该
ffmpeg('video.mov').videoBitrate('512k')
.output('./output/video.mov')
.on('error',function(err,stdout,stderr) {
console.log('Cannot process video: ' + err.message);
});
并分别
ffmpeg('video.mov').screenshots({
count: 1,size:'640x480'
});