Search code examples
amazon-web-servicesvideoamazon-s3progressive-download

S3 Restricted Bucket Progressive Download


I have videos stored in a restricted bucket on Amazon S3. Once a user logs into their account, viewing the video page will generate a signed url for a given video, allowing it to be viewed via progressive download.

The videos are variable in length; some are just a few minutes long, and some are as long as ten minutes. Initially, I had set the signed urls' timeout to be five minutes, but as some of the videos are longer than that, customers were seeing the videos getting cut off. As a result, I increased the signed url timeout to be as longer than the longest video.

I would like to know if it's possible for me to set the timeout back down to a shorter amount, instead allowing the videos to call a new signed url in order to get the next chunk of the progressive download.


Solution

  • Standard video players have no concept of Amazon S3 pre-signed URLs, so they would not be able to "call back" to your application to request a new URL. You could write your own video player (based off Open Source code), but that would be a lot of work for this little benefit.

    When your application generates the pre-signed URL, it could take a look at the length of the video (somehow, perhaps via metadata or an estimate based on the size of the object) and set the expiration time accordingly.

    You might also want to investigate serving video files via Amazon CloudFront RTMP distributions. CloudFront can provide security via pre-signed URLs and also signed cookies. It would be more difficult for people to download content from an RTMP distribution than an Amazon S3 bucket.