Closed biigpongsatorn closed 5 months ago
I finally found out the solution! And what I miss is I have to add input and output format
.inputFormat('mp4')
.outputFormat('mp3')
example
private async getOutputStream(props: {
inputStream: AxiosResponse;
output: {
bucketName: string;
key: string;
};
}): Promise<
CompleteMultipartUploadCommandOutput | AbortMultipartUploadCommandOutput
> {
const output = props.output;
const passThrough = new PassThrough();
const upload = new Upload({
client: this.client,
params: { Bucket: output.bucketName, Key: output.key, Body: passThrough },
queueSize: this.CONCURRENCY,
partSize: this.PART_SIZE,
leavePartsOnError: false,
});
// Convert vdo to mp3 and upload to s3
ffmpeg(props.inputStream.data)
.inputFormat('mp4')
.outputFormat('mp3')
.on('start', () => {
console.log('Processing....');
})
.on('error', (err) => {
console.log('An error occurred: ' + err.message);
})
.on('end', () => {
console.log('Processing finished !');
})
.pipe(passThrough, { end: true });
return await upload.done();
}
Hi,
I'm trying to write a Node.js code that stream downloads a video file from a URL and then stream converts it to an MP3 file, and then stream uploads the MP3 file to an AWS S3 bucket. I'm using the axios library to download the file and the aws-sdk library to upload the file to S3.
For the conversion part, I'm trying to use the node-fluent-ffmpeg library, but I'm running into some issues. Here's the code I have so far:
Version information
Code to reproduce
s3StreamClient.ts
main.ts
(note: if the problem only happens with some inputs, include a link to such an input file)
Error
Checklist