簡體   English   中英

在nodejs中通過fluent-ffmpeg合並多個視頻文件和stream

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM