I am trying to merge multiple video files into stream output using fluent-ffmpeg. But it only streams the first video.
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})
Any ideas?
Yes, though I have this done without fluent-ffmpeg. Instead, spawning ffmpeg and using an input file that lists the files to merge in the correct order.
import { spawn } from 'child_process';
The input file should look like:
file 'path/to/webm1.webm'
file 'path/to/webm2.webm'
file 'path/to/webm3.webm'
Then call ffmpeg
await spawn('ffmpeg', [
'-y',
'-safe', '0',
'-f', 'concat',
'-i', 'path/to/ffmpeg-input.txt'),
'-c', 'copy',
'path/to/finalvideo.webm')
]);
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.