[英]merge multiple video files and stream by fluent-ffmpeg in nodejs
我正在尝试使用 fluent-ffmpeg 将多个视频文件合并到 stream output 中。 但它只播放第一个视频。
res.set('content-type', 'video/webm');
var proc = ffmpeg()
.mergeAdd('file-1.webm') // tried with input()
.mergeAdd('file-2.webm')
.mergeAdd('file-3.webm')
.format('webm')
.size('680x?')
.on('end', function() {
console.log('file has been converted succesfully');
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
// save to stream
.pipe(res, {end:true})
有任何想法吗?
是的,尽管我在没有 fluent-ffmpeg 的情况下完成了这项工作。 相反,生成 ffmpeg 并使用输入文件列出要按正确顺序合并的文件。
import { spawn } from 'child_process';
输入文件应如下所示:
file 'path/to/webm1.webm'
file 'path/to/webm2.webm'
file 'path/to/webm3.webm'
然后拨打ffmpeg
await spawn('ffmpeg', [
'-y',
'-safe', '0',
'-f', 'concat',
'-i', 'path/to/ffmpeg-input.txt'),
'-c', 'copy',
'path/to/finalvideo.webm')
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.