awslabs / amplify-video

An open source Category Plugin for the AWS Amplify-CLI that makes it easy to deploy live and file based streaming video services and integrate them into your Amplify applications.
https://www.npmjs.com/package/amplify-category-video
Apache License 2.0
267 stars 56 forks source link

AWS Amplify ACL protected video playback #180

Closed hphirke closed 3 years ago

hphirke commented 3 years ago

Note: If your question is regarding the AWS Amplify Console service, please log it in the official AWS Amplify Console forum

Which Category is your question related to? AWS Media Convert using AWS amplify What AWS Services are you utilizing? AWS Media Convert & AWS amplify Provide additional details e.g. code snippets We are trying to access Video which are protected via ACL of AWS Amplify. We want to transcode the videos using Media Convert. After the videos are converted they are broken in parts (segments and m3u8 file and etc)

So how can the segments be accessed by the Video player when we pass the m3u8 file which has the right token?

wizage commented 3 years ago

Hey @himanshuphirke

If the content is hosted in S3 and is public, then the m3u8 file works as is.

If your content is hosted in S3 and you want to protect it, like downloading if via IAM or using Amplify.Storage. Currently today most video players don't support this. The reason why this is so, is that a video player reads the m3u8 file (a playlist of sorts) to find the video chunk it needs. The video chunk then needs to be given separate role to pull that chunk down. This all is run in real time by most video players, and while some players allow you to add cookies/modifications to the url, none provide any async methods to do this.

In our plugin, if you need to have protected content we recommend using CloudFront as you can create a token with the initial playlist request with a * policy for all the files matching a pattern.

You can read more about the CloudFront implementation here: https://github.com/awslabs/amplify-video/wiki/Play-Assets

wizage commented 3 years ago

Closing due to inactivity

hphirke commented 3 years ago

@wizage Thanks for the response. We found an player (Expo AV) which supports Cookies in Header request. So the provided cookie is used to fetgch each segment of files. The CDN authenticates usuig the cookie.