首先很抱歉,如果问题重复。但我无法在其他问题中找到正确答案。
我正在尝试使用流和 fluent-ffmpeg 连接 AWS S3 mp4 文件。我设法下载并上传了连接的文件,而无需将其存储到磁盘。
串联似乎是正确的,但是当我选择视频播放器(VLC 媒体播放器或 QuickTime)时间条的时间点时,音频和视频似乎不同步。
这是 nodejs fluent-ffmpeg 实现:
concatenation = (listFileName, passthroughStream) => {
return new Promise((resolve) => {
let command = ffmpeg().input(listFileName)
.inputOptions(['-f concat', '-safe 0', '-protocol_whitelist', 'file,http,tcp,https,tls'])
//.videoCodec('libx264')
.outputFormat('mp4')
.outputOptions('-movflags frag_keyframe+empty_moov')
var ffstream = command.on('end', function() {
const result = 'files have been merged succesfully';
resolve(result);
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
reject(err);
}).pipe(passthroughStream);
ffstream.on('data', ((chunk) => {
console.log('ffmpeg just wrote ' + chunk.length + ' bytes');
}));
});
}
我在文件中使用 S3 文件签名 URL。像这样:
file 'https://bucket.s3.region.amazonaws.com/file_0.mp4'
file 'https://bucket.s3.region.amazonaws.com/file_1.mp4'
我认为这不同步是因为输出碎片化,如果不下载文件可能无法做到这一点,但也许有一个可能的解决方案。
有没有办法在不将文件存储到磁盘的情况下进行 mp4 连接?还是我做错了什么?