Send Apple HLS content to Amazon S3 using Wowza Streaming Engine

The Stream Targets feature in Wowza Streaming Engine™ media server software allows you to send live streams to widely distributed destinations. 

This article explains how to create a Fastly stream target with a push connection to distribute your live streams using Wowza CDN on Fastly. You will need an Amazon AWS account and a Wowza Video account for this workflow.

Alternatively, you may configure your connection for a pull-based workflow where the destination pulls the stream data from the server. 

Unless there is a specific need for a push-based workflow, it's strongly recommended to use a pull-based workflow instead. See Migrate to Wowza CDN on Fastly to learn more about the advantages and disadvantages of the push and pull workflows. 

To configure your stream target using a pull connection, see Stream to Wowza CDN from Wowza Streaming Engine.

Video tutorial: Send Apple HLS content to Amazon S3 using Wowza Streaming Engine with a push-based workflow


See how to configure your connection to Wowza CDN on Fastly for a push-based workflow.

Before you start


You should have access to the following items:

  • A valid Wowza Streaming Engine license and a Wowza CDN subscription. Contact sales@wowza.com for more information.
  • An Amazon Web Service account with create, read, and write access to S3 storage using access key security credentials. See AWS Free Tier to create a free account.

1. Create a bucket in AWS S3

See Creating a bucket for instructions on how to create a bucket in AWS.

You'll need to configure some settings to allow streams to be played back from your S3 bucket.

Configure the following:

  • ACLS must be enabled. For best results, the Object Ownership should be set to the Object Writer.

Graphical user interface, application

Description automatically generated

  • Public Access must be enabled for objects in the bucket.

Graphical user interface, text, application

Description automatically generated
 

  • For testing direct playback from the bucket, you may need to enable Cross-origin resource sharing (CORS). After the bucket is created, select the Permissions tab for the bucket and add the following CORS configuration.
     
    Note: CORS is only required for direct playback from the bucket. It's not required for playback via the Fastly Custom Stream Target.
[ 
    { 
        "AllowedHeaders": [], 
        "AllowedMethods": [ 
            "GET" 
        ], 
        "AllowedOrigins": [ 
            "*" 
        ], 
        "ExposeHeaders": [] 
    } 
] 

Once your bucket is created, you'll need to record the following information from your amazon account:

  • Bucket name, for example my-s3-bucket
  • Bucket Region, for example us-west-1
  • AWS Bucket URL. This will be used with the Fastly Custom Stream Target. The format for the AWS BucketURL is https://[bucket-name].s3.[region].amazonaws.com/ 

    For example, https://my-s3-bucket.s3.us-west-1.amazonaws.com/
     
    For buckets in the us-east-1 region, AWS doesn't require the region in the URL (https://[bucket-name].s3.amazonasw.com/). This is a legacy format AWS URL. It won't work with Fastly Custom Stream Targets. Instead, you need to use the regionalised S3 URL for us-east-1, which is https://[bucket-name].s3.us-east-1.amazonaws.com

You'll also need to record your IAM credentials. These are set per user in AWS. See Create an IAM admin and user group in AWS for more information.

Record the following:

  • Access ID, for example AKIAI6234VXXREN3KWJQ
  • Secret Access Key, for example y1PFFPOEwSrUfvvvdalA1qs9sFDM7+QzQTMHoqP7

2. Enable the Wowza Streaming Engine stream target

Before you stream, you must enable the Stream Targets feature for the Wowza Streaming Engine application or the individual stream target you created.

In the contents panel of your application, if you don't see a checkmark next to Stream Targets, click Stream Targets in the contents panel and then click Enable Stream Targets.

When Stream Targets is enabled, a checkmark appears next to Stream Targets in the contents panel and the Stream Targets page shows Status is Enabled.

3. Create a stream target in Wowza Streaming Engine to send the stream to AWS S3

Once you have created your AWS S3 bucket and recorded your credentials, you'll need to add a new map entry to the PushPublishMap.txt file. See About map entries for more information about map entries.

  1. Locate and edit the PushPublishMap.txt file. The default map file location is [install-dir]/conf/[application]/PushPublishMap.txt. The map file is automatically created for you in this location when you enable the Stream Targets feature.
  2. You'll need to add a new entry to the PushPublishMap.txt.
     
    Note: Each Entry in the map file must be on a single line.

You can use the following sample code, making sure to:

  • Set http.relativePlaylists to true. It is set to false by default.
  • Set the>stream_name[_xxx]to match the incoming stream name or transcoder rendition for each stream target.
  • Set entryName to a unique name for your stream target.
    For Adaptive Bitrate streams, set adaptiveGroup to the same value for each stream entry.
  • Set cloudstorage.string.bucketName to the Bucket Name provided by AWS in Step 1.
  • Set cloudstorage.string.region to the Bucket Region provided by AWS in Step 1.
  • Set cloudstorage.string.accessID to the Access ID provided by AWS in Step 1.
  • Set cloudstorage.string.secretAccessKey to the Secret Access Key provided by AWS in Step 1.
  • For adaptive bitrate streams, include the "adaptiveGroup": "group_name" parameter, which must be the same for each rendition in the ABR stream.
  • Change any additional values to be unique to your stream target.
  • Before saving the file, use a JSON Validator, such as https://jsonlint.com, to validate the map entries. Copy the complete text after the = sign into the validator to check the syntax.
     
    Note: The difference between the single bitrate entry and the ABR entries is the addition of the adaptiveGroup parameter, which groups all the renditions together. The ABR stream will also have a slightly different URL format for playback.

Sample code — Single bitrate map entries

stream_name={"entryName": "WSC_via_S3", "streamName": "stream_name", "profile": "cupertino-cloudstorage", "cloudstorage.provider": "S3", "cloudstorage.string.provider": "S3", "cloudstorage.string.bucketName": "my-s3-bucket", "cloudstorage.string.region": "us-west-1", "cloudstorage.string.accessID": "AKIAI6IO5VXX-EXAMPLE", "cloudstorage.string.secretAccessKey": "y1PFFPOEwSrUfWyhalA1qs9sFDM7+QzQ-example", "debugLog": false, "cloudstorage.transportDebug": false, "http.relativePlaylists": true}

Sample code — Adaptive bitrate map entries

stream_name_720p={"entryName": "WSC_via_S3_720p", "streamName": "stream_name_720p", "adaptiveGroup": "myStream-ABR", "profile": "cupertino-cloudstorage", "cloudstorage.provider": "S3", "cloudstorage.string.provider": "S3", "cloudstorage.string.bucketName": "my-s3-bucket", "cloudstorage.string.region": "us-west-1", "cloudstorage.string.accessID": " AKIAI6IO5VXX-EXAMPLE ", "cloudstorage.string.secretAccessKey": "y1PFFPOEwSrUfWyhalA1qs9sFDM7+QzQ-example", "debugLog": false, "cloudstorage.transportDebug": false, "http.relativePlaylists": true} 

stream_name_360p={"entryName": "WSC_via_S3_360p", "streamName": "stream_name_360p", "adaptiveGroup": "myStream-ABR", "profile": "cupertino-cloudstorage", "cloudstorage.provider": "S3", "cloudstorage.string.provider": "S3", "cloudstorage.string.bucketName": "my-s3-bucket", "cloudstorage.string.region": "us-west-1", "cloudstorage.string.accessID": " AKIAI6IO5VXX-EXAMPLE ", "cloudstorage.string.secretAccessKey": "y1PFFPOEwSrUfWyhalA1qs9sFDM7+QzQ-example", "debugLog": false, "cloudstorage.transportDebug": false, "http.relativePlaylists": true} 

  1. Sign in to Wowza Streaming Engine.
  2. Click Sever on the menu bar, and then click Restart.

    Your new chunklist and playlist in will be loaded into your S3 bucket. This may take up to a minute.
  3. Copy the URL for the playlist from your S3 bucket, for example https://my-s3-bucket.s3-us-west-1.amazonaws.com/myStream/playlist.m3u8
     
    Note: For buckets in the us-east-1 region, this URL will be the legacy format and needs to be changed to include the region. 
  4. Test the playback using the URL for your playlist in your player.
     
    Note: Some players will require CORS headers to be enabled for direct playback from the bucket.

4. Create a Fastly Custom Stream Target in Wowza Video

Note: Only one Fastly Custom Stream Target needs to be created for each S3 bucket.
  1. Sign in to Wowza Video.
  2. Click Advanced on the menu bar, click Stream Targets, Add Target, select Wowza CDN on Fastly, and then click Add.
  3. On the Stream Target Setup page, enter a description Stream Target name.
  4. Check the Enable a Custom Origin checkbox.
  5. Choose your Custom Origin Region from the drop-down menu.
  6. Paste the AWS Bucket URL provided by AWS in step one into the Custom Origin URL field, and click Add.
  7. Record your Custom Origin URL. For example: https://cdn3.wowza.com/5/QkxIcU9SMnh6d3JX/[application-name]/[stream-name]
     
  8. Test playback using your Custom Origin URL in your player.

    You can modify the root address of the playlist URL you copied from your S3 bucket in Step 3 with the Custom Origin URL excluding the [application-name]/[stream-name] to create a .m3u8 file for playback.

    Examples
     

    Custom Origin URL - https://cdn3.wowza.com/5/QkxIcU9S-example/[application-name]/[stream-name] 

    Single bitrate (uses streamName in the URL) 

    S3 URL -  https://my-s3-bucket.s3.us-west-1.amazonaws.com/myStream/playlist.m3u8 

    Wowza CDN URL - https://cdn3.wowza.com/5/QkxIcU9S-example/myStream/playlist.m3u8 

    Adaptive bitrate (uses adaptiveGroup in the URL) 

    S3 URL - https://my-s3-bucket.s3.us-west-1.amazonaws.com/myStream-ABR/playlist.m3u8 

    Wowza CDN URL - https://cdn3.wowza.com/5/QkxIcU9S-example/myStream-ABR/playlist.m3u8

More resources