Ibrahim Abubaker
Ibrahim Abubaker

Reputation: 41

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(). Is there a way to combine audio1 and audio2 and then upload these results back to the s3 bucket?

  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

Upvotes: 0

Views: 270

Answers (1)

Martijn Gastkemper
Martijn Gastkemper

Reputation: 667

You can use 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.

To do that with NodeJS you can try to use the package fluent-ffmpeg/node-fluent-ffmpeg. Or another NodeJS wrapper for ffmpeg.

Upvotes: 1

Related Questions