40

Is there a way to stream MP3s stored on Amazon S3 via a Flash widget embedded in a website, or some other method?

netflux
  • 3,648
  • 6
  • 37
  • 40

2 Answers2

42

Yes it is. Firstly, you need to create a bucket in your S3 account which is all in lower case, is globally unique and is DNS-compatible; so for example I created a bucket called ‘media.torusknot.com’.

Then to make it all look nice you need to create a DNS CNAME entry to map a sub-domain of your site to that S3 bucket. That will allow you to access your files you upload to that S3 bucket via ‘http://media.example.com/somefile.mp3’. You do just need to set the ACLs on the files & the bucket to make sure public access is allowed.

Finally, if you want to stream video files via a Flash player from S3 to another domain, you also have to tell Flash that it’s ok for the content to be pulled in from a different domain. Create a file called ‘crossdomain.xml’ in the bucket, with these contents:

<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
</cross>

That allows the media to be accessed from anywhere - you can be more specific if you want but this is the simplest approach.

Related resources:

Ben Parizek
  • 268
  • 3
  • 16
Konstantin Tarkus
  • 37,618
  • 14
  • 135
  • 121
  • 11
    Keep in mind though, that the media is not really streamed (like with Red5 or Flash Media Server) but progressivly downloaded - thus the media-files end up as easily identified files in the browser's cache. Depending on the license this might be a problem with content copyrighted by a third party – Argelbargel Mar 27 '09 at 13:36
  • Also pay attention to traffic, because if the crossdomain file isnt protecting against other sites linking to the MP3, I believe that anyone could use this MP3 in their Flash player = you pay the bandwidth. But I havent testet it though. – BerggreenDK May 04 '10 at 23:40
  • @BerggreenDK Late response here but you can solve that by making the bucket private and give clients that are authenticated signed urls via an API. These urls would only be valid for a predefined timespan. I would do this regardless as setting a public ACL on S3 in generally not something you want except under specific circumstances such as hosting a website on S3 (see the recent data leaks involving poor bucket policies on S3 which is, hands down, just a matter of bad security policies and lack of knowledge). – Carl Sep 15 '17 at 10:39
38

To update the answer to this question, if you want to actually STREAM to clients, you can use Amazon Cloudfront on top of your S3 bucket (as mentioned by Rudolf). Create a "streaming distribution" in Cloudfront that points to your S3 bucket.

This will stream via RTMP (good for web and Android devices). You can use JW Player or a similar player to play the streamed files.

Cloudfront Streaming uses Adobe Flash Media Server 3.5.

There is also the ability to play secure content using signed urls.

caveman
  • 728
  • 6
  • 9
  • 3
    thanks, this is the info i desperately was looking for! u da man! – r3wt Aug 05 '15 at 06:45
  • 2
    This should be green ticked! – Swaathi Kakarla Dec 29 '16 at 05:20
  • While this seems to confirm we are taking the right path, I don't find free software libraries / players. Is there any, and how should I look for ?Could you bring some examples ? Glancing at existing "RMTP libraries", I find `JWplayer` & `Wowza`, of course, as well as `Adobe flash` and `Gnash`. Isn't there any popular and free HTML based player supporting this ? Did I miss something ? *(I intend to developp a PHP streaming application. On the middle/long run, it should turn commercial, which is one of the reasons why we'll host files on AWS S3)* – Balmipour Jul 11 '17 at 15:35
  • 2
    Nowadays you don't need to use RTMP anymore to get streaming, the S3-native HTTP streaming is perfectly fine and enables streaming playback in a simpler way then RTMP. If you are only looking for audio streaming, just putting the files in S3 is sufficient. If you are looking for video you should consider using HLS or MPEG-DASH (again the files are just in S3). If you have many customers combine that with a CloudFront web distribution for better performance. Apart from the simplicity, this does not require proprietary libraries. – 02strich Aug 12 '17 at 05:15