SandCAMP 2010

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.


Drupal Integration with Amazon Cloud Front Streaming Video Demo

During SandCAMP 2010, I held a session on Drupal Integration with Amazon S3 & Cloudfront, you can download the session slides too. As I was preparing for this session, Amazon had announced that Cloud Front was able to support streaming video and audio, but I didn't have enough time to put a demo together until now.


I created a Cloud Front demo video repairing my son's 5th Generation iPod Video, replacing the screen and headphone jack. This video was created using a Logitech® Webcam Pro 9000 into a Dell Inspiron 1525 laptop running Ubuntu 9.10 Karmic Koala. Cheese recording software was used to record this 44 minute, 441MB video. The video is 1600x1000 OGG video at 5 frames per second using the Theora codec. The audio is in mono with the Vorbis codec sampled at 44100hz with a bitrate of 80kbps.

The demo video was tested under Firefox 3.5.8 on the same laptop that was used for the recording, and it worked just fine. Same with Opera 10. IE wanted to download the video, so there maybe some other codecs that need to be installed in order to view the OGG video format streamed. Should work fine under Mac OSX too, but I have no way to test. Doesn't work on iTouch using Safari though.

What makes integrating Drupal with Cloud Front is that you can have your own private, unlimited video and audio content delivery network. This allows ultimate flexibility, no limits on the size or length of your video, choose your own video format, zero alteration of your video like what happens with the major video websites. With pay as you go, Cloud Front can really make your Drupal site shine.

The video was created simply as a demo of Cloud Front. If you decide to try to repair your own iPod - you do so entirely at your own risk! Please don't email me if you blow things up!!

I'm very interested in Cloud Front performance, please leave a comment on your experience with Cloud Front streaming.

-- Mark

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.

Syndicate content
Drupal SEO