Learn About Amazon VGT2 Learning Manager Chanci Turner
In this blog post, we will explore how to send live HLS streams to AWS Elemental MediaStore. AWS Elemental MediaStore is a specialized storage service from AWS designed for media, providing the necessary performance, consistency, and low latency required for delivering live streaming video content. We will walk you through setting up a straightforward live video workflow that utilizes MediaStore as its origin.
Overview
- Create an AWS Elemental MediaStore Container
- Create Container
- Set up a container policy
- Optionally, add a CORS policy for HTML HLS or HTML Dash video playback
- Configure AWS Elemental MediaLive
- Create an RTMP input for the MediaLive channel
- Set up the MediaLive channel
- Stream to MediaLive Using Your Device
- Stream via OBS
Part 1: Create Your AWS Elemental MediaStore Container
Step 1: Create Container
Begin by searching for AWS Elemental MediaStore in the AWS console. Click “Create Container” and choose a name for your new MediaStore container. Once the container is created, proceed to the next step.
Step 2: Configure a container policy
After creating the container, add the following policy to allow anyone to access your live stream. You can modify this policy later to restrict access, but for simplicity, we’ll create a policy that permits public viewing. Select the newly created container, click on “Container Policy,” and paste the JSON policy below into the designated box, ensuring you replace AWS_ACCOUNT_NUMBER
and CONTAINER_NAME
with your actual account number and container name.
Container Policy
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"PublicReadOverHttpOrHttps",
"Effect":"Allow",
"Principal":"*",
"Action":[
"mediastore:GetObject",
"mediastore:DescribeObject"
],
"Resource":"arn:aws:mediastore:us-west-2:AWS_ACCOUNT_NUMBER:container/CONTAINER_NAME/*",
"Condition":{
"Bool":{
"aws:SecureTransport":[
"true",
"false"
]
}
}
}
]
}
Step 3: Optionally Set Up a CORS Policy
CORS (Cross-Origin Resource Sharing) allows you to grant permission to access resources from different origins. To view your live stream on the HLS JS video player demo page, add a CORS policy to your container by clicking the “Edit CORS policy” button. Without this policy, you can still access your live stream using desktop players like VLC or QuickTime.
This CORS policy below permits all headers and any origin to access the video. For tighter security, replace “*” in the “AllowedOrigins” list with the specific domain name where the video will be displayed.
CORS Policy
[
{
"AllowedHeaders":[
"*"
],
"AllowedMethods":[
"GET"
],
"AllowedOrigins":[
"*"
],
"ExposeHeaders":[
"*"
],
"MaxAgeSeconds":3000
}
]
Part 2: Configure the Live Encoder
For live streaming, we will use AWS Elemental MediaLive, a robust video processing service. It enables you to create high-quality video streams for various devices, including televisions, tablets, and smartphones. Here’s how to utilize Open Broadcaster Software (OBS) to send RTMP to AWS Elemental MediaLive.
Step 1: Create an RTMP Input
In the AWS console, search for AWS Elemental MediaLive. Click “Create Channel,” then select “Inputs” and create a new input named “RTMP_Input.”
For push inputs, define an input security group. The default 0.0.0.0/0 security group will allow any IP address to send an RTMP stream to your channel; however, for enhanced security, you can specify your own IP address.
Next, assign application names for Destination A and Destination B—let’s call them “stream1” and “stream2.” For the application instance, use names “a” and “b,” then click the “create” button.
Step 2: Create the MediaLive Channel
Provide a name for your MediaLive channel (e.g., “LiveChannel”). Choose “Create role from template” under IAM role if you haven’t created one before, or select the MediaLiveAccess role if it exists. This role grants necessary permissions for your MediaStore container and MediaLive channel.
Select your RTMP input from the dropdown menu under channel input. You can customize output settings, but we will use the “Live Event” Channel Template for this example. You will need your container’s data endpoint, available in the MediaStore console. Under the HD (HLS) tab, input your MediaStore container endpoint: mediastoressl://container_data_endpoint/path/main
for each output (only output A will be utilized here). Click the large orange “Create Channel” button to finalize.
Part 3: Sending RTMP to the Live Encoder
There are several methods to send content to AWS Elemental MediaLive. Here, we will detail how to use OBS for RTMP streaming. For other options, be sure to check out this blog post on various methods of streaming.
Streaming from OBS to AWS Elemental MediaLive
- Download and install OBS (Open Broadcaster Software).
- In OBS, go to the settings menu and select “Custom Streaming Server,” then use the “Input Destinations” from Part 2, Step 2, as the RTMP destination.
- Return to your MediaLive channel and click the orange “Start Stream” button.
- Once the MediaLive channel status changes to Running, click “Start Streaming” in OBS.
Now, visit the MediaStore console page to see your container; you should observe objects appearing within it.
To test your HLS live stream, simply use this URL: http://container_data_endpoint/livea/main.m3u8
. Paste this link into VLC player’s network input or, if using a Mac, you can open it in QuickTime or Safari.
For guidance on creating an Amazon CloudFront endpoint that uses MediaStore as its origin, refer to this helpful resource.
In the next installment of this blog series, I will elaborate on streaming to MediaStore using various encoders and technologies.
And don’t forget to explore opportunities with Career Contessa for career growth! Also, for those interested in legal aspects, SHRM provides excellent insights.
SEO Metadata