Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read remote video on Amazon S3 using ffmpeg

I need to create poster frames from videos hosted on Amazon S3 via ffmpeg.

So is there a way to use the remote video file directly in ffmpeg command line like this:
ffmpeg -i "http://bucket.s3.amazonaws.com/video.mp4" -ss 00:00:10 -vframes 1 -f image2 "image%03d.jpg"

ffmpeg just returns:
http://bucket.s3.amazonaws.com/video.mp4: I/O error occurred
Usually that means that input file is truncated and/or corrupted.

I also tried forcing ffmpeg to use the videos mp4 container for reading:
ffmpeg -f mp4 -i "http://bucket.s3.amazonaws.com/video.mp4" ...
But no luck.

Wget this video from S3 and processing it locally works fine of course,
as well as reading the file remotely from other 'standard' http servers.
So I know that ffmpeg supports remote file reading, but why not on S3?

like image 687
virtualize Avatar asked Apr 20 '10 17:04

virtualize


People also ask

Does AWS use FFmpeg?

We use FFmpeg to process the audio stream, but the same concept may work with other media processing tools as well. A foundational knowledge of Lambda, Amazon S3, AWS Identity and Access Management (IAM), FFmpeg, Boto3, and Python scripting language is recommended to build this workflow.

How do I access my Amazon S3 data?

In the Amazon S3 console, choose your S3 bucket, choose the file that you want to open or download, choose Actions, and then choose Open or Download. If you are downloading an object, specify where you want to save it.

Can S3 host videos?

You can use Amazon S3 with Amazon CloudFront to host videos for on-demand viewing in a secure and scalable way. Video on demand (VOD) streaming means that your video content is stored on a server and viewers can watch it at any time.


2 Answers

Nevermind, I found an easy way to solve my problem.

I set up an amazon cloudfront download distribution pointing to my S3 bucket.
Via cloudfront the files are accessible with ffmpeg over http:

ffmpeg -i "http://subdomain.cloudfront.net/video.mp4" -ss 00:00:10 -vframes 1 -f image2 "image%03d.jpg" 

And the data transfer is even cheaper! But still wondering why this won't work with S3 directly...

like image 186
virtualize Avatar answered Sep 25 '22 17:09

virtualize


For everyone who came here looking how to do this with S3 only, The AWS SDK can now generate presigned urls.

ffprobe -i "$(aws s3 presign s3://MY_BUCKET/MY_FILE --expires 5)" 
like image 32
Stefan Avatar answered Sep 23 '22 17:09

Stefan