-->
Save your seat for Streaming Media NYC this May. Register Now!

How To Get Started With Amazon Cloudfront Streaming

In December 2009, Amazon announced that its AWS (Amazon Web Services) Cloudfront content delivery service would support on-demand RTMP streaming from Flash Media Server 3.5. (see Amazon's CloudFront Now Offers Flash Streaming, This Will Disrupt The Market. In practice, this offers a new, flexible low-cost CDN solution, particularly for users with relatively small or intermittent streaming delivery needs. AWS charges only for bits stored and bits transferred. There’s no monthly minimum, no sign up fee or setup fees, and no ongoing costs unless you’re actually using the service.

In this how-to article, we’ll walk through the steps of setting up Cloudfront streaming and getting it working on your site:
1. Set up an AWS Simple Storage Service (S3) account where your content will live
2. Create a "bucket" in S3 to store your media files
3. Move content to your S3 bucket and set its permissions to allow public access
4. Set up a Cloudfront streaming distribution that points at your S3 storage bucket
5. Now you’re ready to stream!

If you’ve never signed up for an AWS account, you may want to go to the Amazon Web Services Sign Up page and do that first. Now, let’s look at each step individually.

1. Set up an AWS Simple Storage Service (S3) account where your content will live
You can set up an S3 account by going to the AWS S3 Page and clicking on the Sign up for Amazon S3 button. You’ll be asked for your Amazon.com login, if you have one (it’s the same one you use for Amazon shopping); or you can set up new login credentials. After reviewing the pricing and entering your credit card number (or confirming a card associated with your existing Amazon account), you’ll receive an email from AWS containing a link to the credentials associated with your S3 account.

On this credentials page, the only thing we need to pay attention to for the purposes of this tutorial are the Access Keys: one Access Key ID and one Secret Access Key.

2. Create a "bucket" in S3 to store your media files
There are lots of tools for interacting with S3 and other AWS services. In this tutorial, we’re not going to focus on tools, but rather on the actual configuration of the service. Once you understand that process, you can use whatever tools you like to work with AWS.

Since it’s free and runs on any operating system, in this example, we’ll use the free Firefox plugin, S3Fox, to work with our S3 account. Once you’ve installed S3Fox, choose S3 Organizer from the Firefox tools menu.

Figure 1 shows S3Fox loaded in the browser.

Figure 1
Figure 1. The S3Fox Organizer.

Click on Manage Accounts at the upper left, and you’ll be prompted to enter an account name, your Access Key ID and Secret Access Key (see Figure 2).

Figure 2
Figure 2. Configuring S3Fox with your S3 account.

In AWS-speak, folders are referred to as buckets. Create a bucket for your streaming files by clicking on the New Bucket icon on the right-hand side of the screen (see Figure 3).

Figure 3
Figure 3. Creating a new bucket in S3Fox.

The bucket name you assign here is global to the entire S3 system, so you’ll need to choose something unique. In this example, I chose to build off of my domain name (see Figure 4).

Figure 4
Figure 4. Naming your S3 bucket.

3. Move content to your S3 bucket and set its permissions to allow public access
Let’s go ahead and drop a file in here now, so it’ll be ready when we set up the distribution. Cloudfront supports all the formats supported by Adobe FMS (Flash Media Server) 3.5, which include the FLV and MP4 container formats, and the Sorenson Spark, H.264 and VP6 video codecs. Once you’ve selected a file from your computer and moved it to S3, you’ll need to set the permissions on the file (not the bucket) to be publically readable. Right-click on the file and choose Edit ACL, then select ‘Read’ by ‘Everyone’ (see Figure 5).

Figure 5
Figure 5. Setting file permissions to public.

Now we’re done with the S3 configuration.

4. Set up a Cloudfront streaming distribution that points at your S3 storage bucket
If you haven’t already signed up for Amazon’s EC2 and Cloudfront services, you’ll need to do that now. Go to the AWS Management Console and follow the prompts to set up your account. Once that’s done, go back to the AWS Management Console and click on the Amazon Cloudfront tab…and yes, go through the sign-up process for that.

With all the sign-ups done—AWS, S3, EC2, and Cloudfront—we’re finally done signing up and are ready to create a Distribution, which is simply a connector between an S3 storage area and the Cloudfront delivery network. Return to the Cloudfront screen and click on Create Distribution. Select your S3 bucket from the pulldown and select Delivery Method: Streaming. If you’d like to set up a subdomain of your own domain that will point to the Cloudfront streaming service, enter it as a CNAME here. In this case, I’ve used streaming as a subdomain of learningapi.com to make streaming.learningapi.com (see Figure 6).

Figure 6
Figure 6. Creating the Cloudfront distribution.

Now you’re finished and you can see your streaming distribution configuration (see Figure 7).

Figure 7
Figure 7. The Completed Cloudfront distribution configuration.

The key information on this screen is the Domain Name: in my case, s2v9at17xgxf0u.cloudfront.net. If you’ve chosen to use a CNAME, you’ll need to go to your domain’s web host to finish that configuration. In the this case, I had to ask that streaming.learningapi.com be set up as a CNAME to s2v9at17xgxf0u.cloudfront.net.

Either way, this is ready to stream. The URL to your new Cloudfront streaming looks like this…

rtmp://[domain_name]/cfx/st/[filename]

…where the [domain_name] is either the Cloudfront domain name shown on your AWS Cloudfront Management page (shown in Figure 7), or the CNAME you’ve set up with your web hosting provider. The /cfx/st/ is the pathname for Cloudfront streaming and is required. The [filename] matches the file you placed in your S3 bucket.

Working Example
By going through these simple steps, it took me less than an hour to get going with Cloudfront on-demand streaming. At this time, live streaming is not supported, although Amazon has announced that they are planning to add that feature in the future.

A working example of the Cloudfront streaming service set up during this tutorial, along with the embed code and the syntax for referencing an rtmp stream using the JW FLV Player can be found on the Cloudfront Streaming Example page at learningapi.com.

Streaming Covers
Free
for qualified subscribers
Subscribe Now Current Issue Past Issues
Related Articles

Amazon Demos Dynamic Content Delivery Service

Attendees at the Content Delivery Summit got an unplanned brief demonstration of Amazon's dynamic content service.

CDS Keynote: Twitpic Grows with Amazon CloudFront

Twitpic's traffic grew over one hundred times, and its storage needs rapidly expanded. Amazon Web Services provided the solution.

Amazon Readies Netflix-like Movie Streaming Service

Leaked details show that Amazon will challenge Netflix with its own all-you-can-stream online video service. The offering will be built on Amazon Prime, so subscribers will also gain free two-day shipping on purchases.

Amazon Plans Streaming Subscription Service

Already a player in video-on-demand, Amazon is now trying to enter the subscription market.

How to do Dynamic Streaming with Flash Media Server

Dynamic streaming with Flash Media Server isn't difficult, but there are a few details to be aware of to make sure your efforts are successful.

Companies and Suppliers Mentioned