How to read remote video on Amazon S3 using ffmpeg

30,252

Solution 1

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...

Solution 2

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)"

Solution 3

In my case, reading directly form S3 bucket work like a charm. To be more specific, my S3 object has private permission so I'm passing a Signed-URL to ffmpeg.

I use ruby and AWSRubySDK to generate a Signed-URL. http://docs.amazonwebservices.com/AWSRubySDK/latest/AWS/S3/S3Object.html#url_for-instance_method

Check your S3 object's permission.

Share:
30,252
virtualize
Author by

virtualize

Updated on July 19, 2022

Comments

  • virtualize
    virtualize almost 2 years

    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?

  • bskinnersf
    bskinnersf about 14 years
    I had the same issue, pulling from the bucket directly doesn't work. It also didn't work pulling the video through Limelight's CDN. Only worked via cloudfront. Very strange..
  • Lukasz Madon
    Lukasz Madon over 10 years
    Works for me when I add bucket policy
  • weisjohn
    weisjohn about 10 years
    I think it may help to specify the -ss value first, re: stackoverflow.com/questions/18534835/…
  • Somename
    Somename about 7 years
    @LukaszMadon what bucket policy did you add?
  • Ahmad hamza
    Ahmad hamza almost 7 years
    What specific command did u use with ffmpeg for signed urls ? I'm getting bad request error. Also it works perfectly fine for normal urls.
  • Chetan Vashisth
    Chetan Vashisth about 4 years
    how do we access the ffmpeg on aws lambda?
  • Mmm
    Mmm about 4 years
    Thanks, this was very useful! The current link to the .Net SDK page presign is docs.aws.amazon.com/AmazonS3/latest/dev/…