简体   繁体   中英

Save output file into AWS S3 Bucket

Using the FFmpeg I'm trying to output file to the s3 bucket.

ffmpeg -i myfile.mp4 -an -crf 20 -vf crop=200:200 -s 800x600 -f mp4 pipe:1 | aws s3 cp - s3://my.test.bucket

As I'm already advised that this cannot be done since creating an mp4 file requires seeking and piping doesn't allow seeking. if I change this command to store the file on the local disk

ffmpeg -i myfile.mp4 -an -crf 20 -vf crop=200:200 -s 800x600 myfile.mp4

it will store locally under project root folder which is fine.

But since I'm running my app from the container and the ffmpeg itself is installed in the Dockerfile I'm trying to figure out what are the possible options here? (if mp4 cannot be stored on S3 from ffmpeg command).

I need to download the output file myfile.mp4 into the server path if I use IWebHostEnvironment where it would actually be saved? is it inside container? Can I mount some s3 bucket folder into docker file and use it from the actual ffmpeg command again?

Since my input file is on s3 bucket and I want my output file to be on the same s3 bucket is there any solution where I wouldn't need to download the output file from the ffmpeg and upload it again?

I guess this is a lot of questions but I feel like I run into a rabbit hole here.

There are really a lot of questions. :D

To make it fair, a few questions from me, to see if I understand everything.

Where is your docker container running? Lambda, ec2 machine, kube.netes cluster?

If it is on ec2, you can use https://aws.amazon.com/efs/ but....

Can you simply save the file in /tmp? And then make an aws s3 cp command from tmp folde?

In some environments (for example lambda), /tmp was the only place where I had programmatically access to file system.

Although if I understand correctly, you have write rights in your environment? Because you download the original image from s3 bucket. So can you do something like this?

  1. download source file from s3
  2. create new file with ffmpeg
  3. uploaded the file to s3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM