Tag Archives: cloudfront

Experimenting with Streaming on a CDN

Experimenting with Streaming on a CDN

Recently I was asked to post a copy of the film I just finished cutting online for a producer in Europe to view. This meant I would need to encode a Flash Video file (FLV) or an H.264 MP4, and I would need to find someplace secure to host it online. On this and previous projects, I’ve often uploaded Quicktimes directly to my website and sent a link and login credentials to whoever needs them. If the recipients are in the United States, my hosting plan at MediaTemple is more than adequate to serve up a Quicktime or two. For slightly longer cuts I’ll usually go the extra step of encoding a FLV and directing the recipient to an HTML page with a flash player set up to play the FLV. I have also uploaded a 90-minute cut in FLV format to my server, but a couple people I sent it to had problems playing it all the way through, and when they had to reload the page they were forced to start downloading the 1.2GB file from the beginning.

In this case, since the producer is in Germany, I wanted to be able to provide him a quick, localized download, as well as the ability to jump to any part of the film instantly. This is a feature you find on most major video sites, and if your connection gets disrupted or you need to reload the page for whatever reason, you can pick up right where you left off with minimal downtime. Unfortunately I don’t have enough control of my MediaTemple server to install the appropriate software for this kind of streaming. Also, my server is located in Los Angeles, and having lived in Europe I’m well aware of how slow it is to transfer files transcontinentally. What I needed was a RTMP server in Europe, and without doing very much research I opted to try out Amazon Cloudfront.

The video below is an example hosted from my Cloudfront account. I didn’t have much I could put online publicly, so please enjoy the credits from a short film I cut called The Happiest Man Alive.

[jwplayer file=”HMA_Credits2.mp4″ streamer=”rtmp://s20fxl9ko2l7i5.cloudfront.net/cfx/st/mp4″ provider=”rtmp”]

Amazon Cloudfront

Amazon Cloudfront is an extension to their popular S3 file hosting service. The way S3 works is that you upload whatever files your website requires to Amazon S3’s servers, and then they take care of making sure that when someone requests your website, the appropriate files are transmitted from a server closest to the requestor. So for example, a user in Japan would download images on your website from an Amazon server in Asia, while in Los Angeles you’d download the same files from a server on the west coast. You pay a few cents per gigabyte of data transferred, but your website loads much faster for everyone worldwide since they’re not waiting to load it from a server half a world away. This is what a Content Delivery Network (CDN) is designed to do, and though most CDNs are designed for big corporations like Apple and Facebook, Amazon happens to run one designed and priced for individuals as well.

What Cloudfront does is add a few more localization controls to S3, as well as a streaming capability. There are other streaming services you can pay for, but for me what gave Cloudfront the edge was the combination of a CDN and streaming service. This way, not only can the producer stream my film in the same way he would watch a clip on Youtube, but it will stream to him from an Amazon server in Frankfurt, Germany, even though I uploaded the file to an Amazon server in the US.

Caveats

As usual, a few caveats.

1) Cloudfront and S3 are not replacements for a host server. They serve up files but they don’t serve up websites. You will still need your own server or a Google Site for your viewers to point their browser at, and you’ll need to configure a Flash player with the appropriate Cloudfront RTMP URL where your file is located.

2) If you don’t want random people seeing your content, make sure to protect the folder containing your HTML page in some way (.htaccess, server-side authentication, etc.). Your hosting provider likely provides at least basic folder password-protection.

3) Cloudfront does offer a “Private Content” option, which allows you to specify a security policy and expiration date in the link you send out to people, however I was not able to get this to work with a RTMP link in either Flowplayer or JW Player. I think once Amazon creates better controls for private content on their web front-end, this might get easier. I was trying to set it up using a 3rd-party Windows app to configure Cloudfront, and I couldn’t get it to work at all. I was also skeptical how secure this “secure URL” would be, considering that anyone with a little brains who somehow got access to that part of my website could copy the RTMP secure URL the same way they could copy an unsecured RTMP URL. You can get a little fancy in the secure URL by embedding a policy that restricts downloading the file to certain IP addresses or until a certain day, but considering that I couldn’t get even the basic template policies to work, I couldn’t explore the security of the fancier policies.

4) On Cloudfront, the first time someone in each worldwide region requests your content, there will be a slight delay as that content is transferred to a server local to that user. From then it will remain on that local server for 24 hours after the last request. So if I upload the file to the LA server and then my German producer requests it, there may be a very slight delay before it starts to stream for him. However, if he goes back to watch it again 12 hours later, it will already be cached on a local Amazon server and will start streaming immediately.