S3: Streaming video with CloudFront

With CloudFront, you can stream your own audio and video without using any code or installing complicated server software. CloudFront is an Amazon service which works in conjunction with your S3 Amazon account (S3 AWS).
What the service basically did so far was to serve content from your S3 account to the closest server in the area of the end user. So, let’s say, you are in the US and you put your videos on the US server of S3 Amazon, a visitor from Great Britain will automatically get a copy of your video via the U.K. server.
As a result, the video downloads quicker then it would from the US server. It doesn’t make a world of difference, but a couple of seconds won is definitely and advantage.  Visitors are generally quite impatient and a couple of seconds might be a decisive factor to stay or move on.

To CloudFront or not to CloudFront

The disadvantage I found so far regarding CloudFront was that all files had to be made public. Since you can make media files private with S3 AWS on its own, I reckoned that CloudFront was not interesting for rich media. After all, public videos can be placed on YouTube, it doesn’t cost you anything and it goes viral. So, why incurring the extra cost? While S3 can be used for private video and audio (see also: S3 Amazon: Expiring URLs). However, my misgivings about CloudFront evaporated suddenly:

I read about the streaming feature which was implemented in December 2009, but the documentation on S3 Amazon can be confusing at times and it looked like you had to install Adobe Flash Server Software, which is expensive and complicated to install and use.
What I did not realize: there is no need to install streaming server software at all.  All you actually have to install is a Flash Player, like JW Media Player, or Flow Player. Not knowing that, I ignored this feature as something for the bigger boys with lots of money to spend, until I bumped into and article by CloudBerryLab: How to configure CloudFront Streaming with CloudBerry S3 Explorer.   It explains how to use CloudBerry Explorer to implement streaming, and I thought, OK, let’s give it a try, and it worked like a charm!

What are the advantages of streaming?

Streaming video, as opposed to progressive download, does not need to be downloaded before it plays. It almost plays immediately(5-8sec.) and you can jump further up in the time line, which is impossible on progressive downloads. YouTube  uses progressive download and  jumping halfway a movie means waiting and waiting until half of the movie is downloaded. You can avoid that with streaming.

Progressive download

With streaming, jumping in the timeline it will not play instantly but let’s say within 5 to 8 seconds depending on the size of the video and your connection.

Demo: Streaming versus Progressive download

Below you find the same video twice, one streaming and one with progressive download. Try to jump to various points in the progress bar. This video is 19Mb 800×450 pixels in size and 1minute, 24 seconds long
Streaming video:

This text will be replaced

Progressive download video:

This text will be replaced

As you may have noticed, playing around: with streaming it is easier to jump ahead to parts that interest you.  This is especially useful if you viewed the video once already and just want to review that part in the middle again. Secondly, streaming video or audio is not downloaded on the computer of the end user. You serve it bit-by-bit.  So, it becomes harder to make a copy of the media and distribute it.
NOTE: I said harder, not impossible. There is software around that can download streams, but at least you stop most people from distributing your content without your consent.

Regarding waiting for content to show up the first time, it is a close call. Streaming appears to be a bit faster starting up, but only marginally.  Jumping ahead goes a lot quicker with streaming video, this is especially advantageous with longer videos of 10 minutes and more.  In fact, with longer videos, streaming is a clear winner because no one has the patience to wait before a video is completely downloaded to jump ahead.
Streaming has other advantages as well but they are beyond the scope of this article.

Progressive download is quicker when you jump back to previous parts.  And when the video is completely downloaded, jumping to any part is faster too. Thanks to CloudFront, downloading is quicker, so with short videos, or audios that need to repeat (loop), progressive download is actually better.

Conclusion

CloudFront gives an improvement on both progressive download and streaming.  If speed is important to you, and given the fact that streaming is an included bonus with CloudFront, you might want to consider signing up for it.  If you have already a S3 account, signing up for CloudFront is easy:

CloudFront signup

How much does it cost?

You have the regular costs from your S3 account (you must keep that account to contain the original files), and on top of that the CloudFront service. As usual, you pay for the bandwidth used. The pricing is more or less the same as with S3 itself, so in theory you can count on it that you pay more or less double of what you pay now. However, and this is a big advantage of streaming; not everyone will play your video or audio until the end, so you won’t be charged the full download every time the visitor clicks the media.  This will compensate for the added cost.  In how far is difficult to say, though.

If you have instructional videos, you will get returning visitors only wanting to review part of the video again, while with entertainment media, you can expect people to play it in full nearly every time. Here is the current pricing for CloudFront.

For most bloggers , artists and entrepreneurs, costs will be minimal, a few dollars monthly. However, to give you an idea what to expect: There was an example in the Amazon forum of a guy using S3 AWS who had a peak of 738GB and that costed him about $340.  For this amount, you can show a video of 50mb 15,160 times, or 3 videos of 25MB 10,106 times each.
Using CloudFront and streaming the video in this case would probably cost around $680 because he would consume 1,400 GB or there about.  This is a rough estimate, of course.  It’s probably a bit cheaper.  Does that sound a lot to you? Well, if you would use AudioAcrobat or Bits-on-the-run, you would pay a lot more!

As I said in previous articles, if you are strapped for money and you are sure your video is going to be a smashing success, you have 2 options: either play it safe and put the stuff on YouTube or monetize your video in some way, using ads, paid membership or whatever.

14 thoughts on “S3: Streaming video with CloudFront

  1. Hello,

    I noticed that you mentioned Bits on the Run. We also know of the benefits of using AWS streaming, and that is why it is now very easy to set up Bits on the Run accounts to use AWS instead of our CDN solutions. All you need to do select “Stream videos through your AWS account” on the signup page and enter your AWS key and secret. That way you you still get the benefits that the BotR solution gives you (use of licensed player, integrated system that creates embed codes for you and takes care of all the heavy lifting, automatic bitrate switching). If you use AWS as your CDN you won’t incur any traffic costs from Bits on the Run, you only pay for the amount of GB (total file size of originals + transcoded videos) that we help you manage.

    By the way, it is also possible to do HTTP progressive downloads with seeks in videos that are not fully downloaded yet. This is called pseudo streaming and most content delivery networks offer that (but Cloudfront download distributions don’t). You can find out more about h.264 pseudo streaming on this page: http://h264.code-shop.com/trac

  2. Hi Remco,

    That is good news. Thanks for the info, Remco. So far, I found Bits-on-the-run quite expensive, but it looks like Amazon is influencing the market in a good way. That said, Bits on the Run does add substantially to the bill on top the S3 AWS account, so be careful out there and plan ahead what you are going to upload if you work with Bits-on-the-run. Don’t be afraid to ask them a detailed pricing upfront by sending them a projection of what you think you are going to use.

  3. Thanks for putting the two examples side by side. I’m experimenting with streaming now, but the frequency of buffering is unacceptable.

    I live in South Korea, so I think that’s the problem. From here, the streaming video buffers every 2 seconds. Very annoying, to say the least. I thought that cloudfront had an Asian edge location in Hong Kong or Japan, but even when I played your video a second time it still buffers every 2 seconds.

    The third time I decided to get my stopwatch out. The 1:24 took a total of 4:05 to complete. From what I can tell, using cloudfront for streaming is not an acceptable solution for targeting Asian users.

  4. Hi Shaun,

    Thanks for this detailed info. CloudFront indeed has a server in Asia Pacific Region in Singapore. How strange, especially since the test movies above aren’t heavy at all, only 13.2Mb.
    Perhaps there are still problems with those servers or they are already over loaded with content. I hope this will be solved soon because that is indeed not the idea of streaming.
    The weird thing is, in South Korea T1 lines are almost a standard connection (much faster then Europe), yet you still have those problems. Goes to show that streaming HD is not for tomorrow.

  5. i’ve been running S3 / CloudFront for a while on a variety of projects now and been really pleased with it. It hadn’t occurred to me that I could apply gzip to them, this is an excellent concept, I’ll be experimenting with it soon…

  6. CF is a horrible option for streaming video simply because of how it’s caching works. You explain how RTMP is great because you can seek, but unfortunately with CF you can’t seek because it’ll be making you wait to copy that part from S3 first. It’s probably the top of the line CDN for anything that’s specifically not streaming video.

  7. Chris, I use CloudFront for a long time now and it works excellent, there is nothing horrible about it. I agree that technically it might not be real streaming but it is as close as it gets and it behaves that way, so all the rest is academic.

  8. There is a recent howto about streaming videos via s3 & cloudfront using HTML5 based video player instead of Jwplayer. I think its a progressive download method

  9. “Hi, How is amazon cloud front better than using an EC2 instance for video streaming?
    Please explain in terms of reachability, scalability and pricing.
    Thanks in Advance

    • Hi Ben Stokes,
      It is not better, it is different. With an EC2 instance you have more options (combined with CloudFront). You can do live streaming, for instance.
      Reachability is for both the same as far as I know. But I’m not into EC2 as I find it expensive and difficult to deal with.
      As for pricing, have a look here: https://aws.amazon.com/ec2/pricing/

Leave a Comment