• How to use Amazon S3 with a Wowza media server

    This article describes how to use Amazon Simple Storage Service (Amazon S3) with a Wowza media server for Amazon Elastic Compute Cloud (Amazon EC2) instance to stream on demand video. Amazon S3 provides a repository for storage of your media files that can be accessed by multiple Wowza media server for EC2 instances. The persistent nature of Amazon S3 storage means that the content is always available to an instance after you launch it.

    Contents



    About Amazon S3


    Amazon S3 is a persistent storage system that's available for EC2 instances. While EC2 instances lose their data when they're shut down, Amazon S3 is an external data source that multiple EC2 instances can readily access. You can store an unlimited number of objects (media files) containing from 1 byte to 5 terabytes (TB) of data in a user-defined bucket in a specific Amazon Region, and secure the data from unauthorized access.

    Pricing for Amazon S3 is managed by Amazon. For more information, see Amazon S3 Pricing. The data that's streamed from Amazon S3 via your Wowza media server for Amazon EC2 instance to your customers is charged at regular Wowza rates. For more information about Wowza media server for EC2 pricing, see Media Streaming on Amazon Web Services (AWS).

    Configuring Amazon S3


    You can use the AWS Management Console to create buckets, store and retrieve your media objects, and manage permissions to the resources. For more information, see the Amazon S3 Console User Guide. The media objects that are stored in your Amazon S3 repository are available for use with other AWS services, including Amazon EC2.

    Streaming on demand from Amazon S3 (vods3)


    Due to the latency associated with streaming video files from an Amazon S3 bucket, Wowza media server AMIs include the built-in vods3 application, which is used to improve performance when streaming content stored on Amazon S3. Any content stored on Amazon S3 should be streamed via the vods3 application.

    The vods3 application uses Wowza Media Cache technology to cache the content in the Amazon EC2 AMI instance store. The caching system works in the following manner:

    • The files are cached on the local instance store the first time a stream is accessed. The system caches block-by-block to minimize startup times on first view.

    • Items are removed from the cache based on a caching algorithm:

      • If the cache isn't full, an item will live in the cache as long as it's being viewed.

      • If an item isn't being viewed, a time-to-live timer starts. The item is flushed from the cache if it isn't viewed for MaxTimeToLive milliseconds.

      • If the cache is full and a new item must be cached, the cached items that haven't been viewed for more than MinTimeToLive milliseconds are flushed from the cache to make room. Items are flushed from the cache in reverse order from the last time they were viewed.

    The vods3 application is included in the default startup package, which is used automatically when you launch a Wowza Media Server for EC2 instance.

    Note: If you load your own startup package when launching an instance, the default startup package won't be used. Your startup package must provide all of the applications that are required for streaming, including the vods3 application. For more information about how to configure startup packages, see the Wowza Streaming Engine for Amazon EC2 User's Guide.

    Playback

    To stream video from Amazon S3, upload a media file to your Amazon S3 bucket and then set your stream name in the following form:
    [media-type]:amazons3/[s3-bucket-name]/[path-to-content-in-s3]
    The amazons3/ part of the stream name identifies that the stream is sourced from Amazon S3.

    Using the above example, you can play the mycoolvideo.m4v file that's stored in the Amazon S3 bucket mybucket at the path videos/coolvideos by using the URLs below.

    Note: Replace [instance-public-dns] with the public domain name of the Wowza media server for EC2 instance.

    Adobe Flash Player (RTMP)


    Server: rtmp://[instance-public-dns]/vods3
    Stream: mp4:amazons3/mybucket/videos/coolvideos/mycoolvideo.m4v

    Adobe Flash Player (RTMP single URL)


    rtmp://[instance-public-dns]/vods3/_definst_/mp4:amazons3/mybucket/videos/coolvideos/mycoolvideo.m4v

    Adobe Flash Player (Flash HDS)


    http://[instance-public-dns]/vods3/_definst_/mp4:amazons3/mybucket/videos/coolvideos/mycoolvideo.m4v/manifest.f4m

    Apple iOS device (Apple HLS)


    http://[instance-public-dns]/vods3/_definst_/mp4:amazons3/mybucket/videos/coolvideos/mycoolvideo.m4v/playlist.m3u8

    Microsoft Silverlight (Smooth Streaming)


    http://[instance-public-dns]/vods3/_definst_/mp4:amazons3/mybucket/videos/coolvideos/mycoolvideo.m4v/Manifest

    RTSP/RTP player or device


    rtsp://[instance-public-dns]/vods3/_definst_/mp4:amazons3/mybucket/videos/coolvideos/mycoolvideo.m4v
    Notes:
    • When streaming using a stream name that includes path elements (for example, mp4:amazons3/mybucket/videos/coolvideos/mycoolvideo.m4v), you must supply both the application name and applicationInstance name as part of the URL. The example URLs above use the default applicationInstance name _definst_.

    • By default, the vods3 application is configured with S3 authorization turned off. This means that all content must be publicly available. For more information about how to stream non-publicly available content, see the Wowza Streaming Engine for Amazon EC2 User's Guide.

    Mounting an Amazon S3 bucket on your Amazon Machine Image


    After you create an Amazon S3 bucket, you can mount it as a local file system with read/write capabilities by using the open source FUSE-based file system s3fs. This enables interaction between the AMI Host operating system and your Amazon S3 bucket. For more information, see How to use the FUSE-based file system backed by Amazon S3.

    Troubleshooting Amazon S3


    Because environments can change over time, go to the Wowza Streaming Engine in the Cloud forum if you have trouble.

    Originally Published: 10-01-2010.

    If you're having problems or want to discuss this article, post in our forum.