Skip to content

How to prevent downloading video from Amazon Cloudfront

0

I use S3 to store my videos and Cloudfront for distribution. I my website, I successfully streamed the videos using the <video> tag. One can see the source URL if they inspect the page. Example: http://cloudfront-domainname/VideoFileName.mp4

If I directly paste this URL in address bar, I am able to download the video by right-click then selecting "Save Video As...". My question is there a way in Cloudfront and/or S3 to prevent this download?

4 Answers
1

Since you are using S3 as the origin for your Videos you can use CloudFront Origin Access Control (OAC), for details see

https://aws.amazon.com/blogs/networking-and-content-delivery/amazon-cloudfront-introduces-origin-access-control-oac/

For S3 use OAC and apply the OAC policy at your bucket.

This way any request from CloudFront to your S3 Bucket will have to be compliant to the OAC Policy that will only allow requests to be served if coming from your CloudFront destribution endpoint.

If you use any other types of Origin Servers or services you can also potentially configure CloudFront to add custom HTTP headers to the requests that it sends to your origin. For more information see: https://someshsrivastava1983.medium.com/secure-custom-origin-with-cloud-front-custom-header-and-aws-waf-9156dc7b5d5b or https://repost.aws/knowledge-center/cloudfront-authorization-header

This way any request to the Origin will add a custom HTTP header, if users inspect your front-end and copy the playback URL they will not be able to access directly your Origin.

AWS

answered 3 years ago

0
Accepted Answer

The short answer is "not easily" and the longer answer is "not at all".

If the user can see the content then they already have the content - this is true for images, videos, text, etc. Even if there was a way to hide the originating link the content is still being streamed to the end user so a determined user could still get access to it. And the reason why video (or images) are sent as a link in this case is so that the browser does all the heavy lifting of rendering the content.

You could build your own rendering code on the front end; coupled with some other code at the back end which avoids a single link - but it's a lot of work and (again) a determined user is going to figure it out.

EXPERT

answered 3 years ago

EXPERT

reviewed 3 years ago

  • I understand. Is there a way within AWS to encrypt the downloaded video?

0

Apart from Bretsski answer maybe there can be a workaround you can use AWS Elemental MediaConvert Service to encrypt your videos I have added the below link for you to track how to

https://docs.aws.amazon.com/mediaconvert/latest/ug/using-encryption.html

EXPERT

answered 3 years ago

0

You can ingest your MP4 on MediaPackage and make it available as HLS. Since HLS is made up of manifests that point to multiple file segments this will make harder for users to use the right-click then selecting "Save Video As..."

Please see the following documentation: https://docs.aws.amazon.com/mediapackage/latest/ug/vod-content.html

Alternatively you can create HLS videos with MediaConvert and serve the HLS content from the S3 bucket in the same fashion you do the MP4. The only difference is that your URL will point to the parent manifest i.e. filename.m3u8 Please see: https://docs.aws.amazon.com/mediaconvert/latest/ug/outputs-file-ABR.html

AWS

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.