Preparing Amazon S3 & CloudFront for Streaming Flash Videos from Your Drupal Site (Part II)

This is Part II of an unknown number of posts about using Amazon S3 & CloudFront to host your Drupal site's streaming media. Part I covered a very basic approach using an Ogg Vorbis Video formatted file delivered over HTTP. Although this will work over HTTP with limited support from embedded media players, this isn't the internet standard for delivering streaming videos. One standard protocol to use is the real time messaging protocol or rtmp, developed by Adobe Systems. From the Amazon CloudFront manual:

"CloudFront uses Adobe Flash Media Server 3.5 to stream on-demand content with Adobe's
Real-Time Messaging Protocol (RTMP). CloudFront accepts RTMP requests over port 1935 and
port 80."

This means flash videos can be streamed from Amazon CloudFront. This post will show how to convert that Ogg Vorbis Video file to flash video format on Ubunta 9.10 and then configure Amazon CloudFront to support streaming the flash video.

 

1. Converting Ogg Vorbis to Flash Video


In order to convert the ogv file to flv format, ffmpeg needs to be installed. On Ubuntu 9.10:

sudo apt-get install ffmpeg

 

2. Convert the ogv file to flv format:

ffmpeg -i iPodVideo5GRepair.ogv -s 800x600 iPodVideo5GRepair.flv

The -s ffmpeg option resizes the video to 800x600. The original video file was recorded at 1600x1000. This reduced the file size from 440MB to 124MB. Still 44 minutes in length though.

3. Create Amazon S3 Bucket

Amazon CloudFront needs an Amazon S3 bucket to store the flv file. CloudFront uses Amazon S3 as the source for the flv file to stream. Amazon CloudFront only supports the distribution of content, not the storage. Using your favorite Amazon S3 client, create a bucket that's named like your internet domain name. In the case of ThetaJoin, a bucket was created named streams.thetajoin.com.

Amazon S3 Bucket

4. Configure Bucket for Streaming Content

CloudFront supports content distribution using two different methods - download and streaming. The download method is used for static content such as PDFs, JPG, or PNG files. The other method is the streaming method that's used to stream either audio or video files. A CloudFront distribution can only support one of these methods at a time, hence the creation of the streams.thetajoin.com bucket to support the CloudFront distribution that will stream the flash video file. Log in to the Amazon Web Services (AWS) Manager to access CloudFront: https://console.aws.amazon.com/cloudfront/home . Once there, the streams.thetajoin.com bucket can be configured to support CloudFront streaming. Click on the Create Distribution button:

Creating Streaming Cloud Front

Choose Streaming for the Delivery Method, select the Amazon S3 bucket, give it a CNAME the same as the Amazon S3 bucket name, and make sure it's enabled. Creating the CloudFront streaming distribution can take some time. AWS Manager will show that the distribution was created:

AWS Manager - CloudFront

The streams.thetajoin.com bucket has the following attributes:

  • Delivery Method: Streaming
  • Domain Name: s9vf9f1gnogon.cloudfront.net
  • Origin Bucket: streams.thetajoin.com.s3.amazonaws.com
  • State: Deployed
  • Status: Enabled

The streams.thetajoin.com bucket is ready to support streaming of any streamable content stored there.

5. Configure DNS

The URL to the CloudFront distribution is s9vf9f1gnogon.cloudfront.net, which is on the ugly side and doesn't maintain your site domain name. It would be great for your site branding to use a portion of the origin bucket URL, streams.thetajoin.com only. To do this, you'll need to configure your DNS server with a CNAME value that's the name of your Amazon S3 bucket, that points to the Domain Name of your CloudFront distribution. In ThetaJoin's case streams.thetajoin.com points to s9vf9f1gnogon.cloudfront.net. Now, when a URL with the domain streams.thetajoin.com is requested from the media player, the DNS server will "redirect" the URL to s9vf9f1gnogon.cloudfront.net. From the end user, it'll look like your streaming content is being delivered from your own private content delivery network.

 

Amazon S3 and CloudFront are configured to support streaming the flash video that was converted in step 1. Part III of this series will show how to add streaming content to your site.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Changing the distribution setting

Hi,
Great post.
However, I'm unsure about one thing.  Let's say I currently have my bucket set up as a "download" distribution.  I now decide that I want to set it as a "streaming" distribution.
Are there any adverse side effects with switching the distribution type back and forth? 

Only CloudFront Supports Streaming Content

A regular S3 bucket doesn't support streaming, it's just a bucket to hold your content you want to stream. You can only stream from Cloudfront.

-- Mark

Hello, The only drawback that

Hello,
The only drawback that I can see is that the prices would increase for download vs. streaming.  More data transfer will take place with the download since the entire file is transferred from the edge location.
I am relatively new to Amazon S3, so other side effects might be inherent with this kind of action.

HTH

Creative Commons License
This work by Mark Schoonover is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
Based on a work at blog.thetajoin.com. All comments copyright their respective owners.

Drupal SEO