[英]How to concatenate and upload audio using Amazon S3 storage
My goal is to retrieve two separate audio files currently stored in an s3
bucket using the getObject()
method and then concatenate both files and upload a combined audio clip of both audio1
and audio2
back to s3
using s3.upload()
.我的目标是使用getObject()
方法检索当前存储在s3
存储桶中的两个单独的音频文件,然后连接这两个文件并使用s3.upload()
将audio1
和audio2
的组合音频剪辑上传回s3
。 Is there a way to combine audio1
and audio2
and then upload these results back to the s3
bucket?有没有办法将audio1
和audio2
结合起来,然后将这些结果上传回s3
存储桶?
const audio1 = await s3.getObject({
Bucket: 'Bucket',
Key: bucket1.audio1.s3Key,
}).promise();
// the second audio file to be concatenated to the first one
const audio2 = await s3.getObject({
Bucket: 'Bucket',
Key: bucket1.audio2.s3Key,
}).promise();
// combine and upload 'audio1' and 'audio2' as a new obj back to s3 bucket
You can use ffmpeg.您可以使用 ffmpeg。 On the command line you could do this:在命令行上,您可以这样做:
ffmpeg -i "concat:audio1.mp3|audio2.mp3" -acodec copy out.mp3
This combines audio1.mp3
and audio2.mp3
into out.mp3
.这将audio1.mp3
和audio2.mp3
成out.mp3
。
To do that with NodeJS you can try to use the package fluent-ffmpeg/node-fluent-ffmpeg .要使用 NodeJS 做到这一点,您可以尝试使用 package fluent-ffmpeg/node-fluent-ffmpeg 。 Or another NodeJS wrapper for ffmpeg.或者 ffmpeg 的另一个 NodeJS 包装器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.