Or it seems so.
There're some details which are documented poorly. I will try to fill this hole.
Brief algorithmTo stream a video (including h264) from Cloudfront, you need to do the following:
- Create an AWS account
- Create an S3 bucket for you videos
- Create a Cloudfront distribution for it
- Upload it to your S3 bucket as a public resource
- Stream it through Flash Player using correct URL
Configuring softwareTo work with S3 and Cloudfront you need some special software. For instance, there's an extension for Firefox called S3Fox. I personally prefer using s3cmd command line program to manage S3, I will provide examples for s3cmd.
Anyway, when registering in AWS, you will get a couple of pretty long and ugly strings. Those are Access Key and Secret Key. You have to configure your AWS-related software to use these keys for authentication. For s3cmd, the command is
Creating an AWS accountTo create an AWS (Amazon Web Services) account.
Creating an S3 bucket for your videosFirst, you have to create an S3 (Simple Storage Service) bucket for your videos, it will feed them to your Cloudfront distributions.
s3cmd mb s3://your-bucket-name.you-site.comBucket name must be unique among all buckets, so it may seem reasonable to call your bucket based on your domain name.
Creating a Cloudfront distribution for your videosA distribution must be bound to a bucket. Distribution will distribute any file with public access from a bucket bound to it.
Distribution may be created using mentioned software or using AWS Console web interface.
When creating, select 'Streaming' as type as we're going to stream video. Note that you can create several distributions for your bucket, so you may also have access to your bucket via HTTP if you wish. Of course, specify your bucket to which distribution will be bound.
Distribution takes some time to create. After it completes, you will get a public domain name for it, this will be domain name you will need to construct video URLs.
Uploading a video to bucketWhen uploading a video to your bucket, make sure that you make it publicly readable.
s3cmd --acl-public put video.mp4 s3://your-bucket-name.your-site.com/video.mp4Note that you don't need to make your whole bucket publicly readable, only files.
Constructing a URLIt's not a trivial task to construct a correct URL for streaming, because RTMP (and we are forced to use RTMP for streaming) has its own logic of constructing URLs. And there's still another catch with correct format prefix which you must use if you stream mp4 (or mp3). So I will provide some examples.
The common schema for Cloudfront is the following:
- for flv, you don't need a type prefix, and you may supply extension name while it's recommented to omit it.
- for mp4, you have to use type prefix 'mp4:' (with no quotes) and you must supply extension (mov, mp4, aac, f4v, m4v, m4a - any of these).
- for mp3, you have to use type prefix 'mp3:'.