amazon-s3 - 音频和视频不同步。使用 fluent-ffmpeg 串流 mp4 文件
问题描述
首先抱歉,如果问题重复。但我在其他问题中找不到正确答案。
我正在尝试使用流和 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 连接?还是我做错了什么?
解决方案
推荐阅读
- javascript - 使可滚动的子 div 独立于父级的滚动
- python - 将 Airflow(版本 1.10.5)与 Bigquery 连接
- python - 将两个数字与对应位置的整数合并在一起(不使用str)
- javascript - JS上的数组仅迭代一次,第二次单击时不显示信息
- postgresql - 获取与函数的选定行/字段关联的字段值
- python - 如何从 Python 将 csv 文件导入 QuestDb?
- mysql - 如何处理涉及不同货币的数据库结构
- oauth-2.0 - Keycloak Gatekeeper/ Luketo Proxy 的替代品
- rust - 如何有效地将切片复制到 Rust VecDeque
- kotlin - 在 Kotlin 中使用 Set 时 assertEquals 无法正常工作