AWS for M&E Blog
How to delay live streaming using AWS Elemental MediaPackage
The ability to introduce a delay into live or real-time streaming video is a critical function for many content providers. There are several reasons a content provider might want to introduce a time lag to a live stream broadcast.
Time zone differences: Delaying a live stream can accommodate viewers in different time zones, serving those who may not be able to watch the live stream in real time.
Legal compliance and content rights: Delaying a live stream can help make sure that the streaming content complies with any legal or regulatory requirements. This helps when service providers have the rights to stream live events with a specific time delay.
Delayed live streaming can be used for a variety of purposes, including broadcasting live events, such as sports or concerts, and for streaming live news coverage. It can also be used for interactive live streaming, where viewers can interact with the content in near real-time, but with a slight delay for smooth and uninterrupted playback. Delayed live streaming can also be used for content moderation, editing, and to address technical issues, such as audio or video problems. Delaying a live stream allows for these issues to be fixed before the content is published.
In this blog post, we describe the step-by-step procedure for setting up AWS Elemental MediaLive for video processing and AWS Elemental MediaPackage for video distribution to generate a delayed live feed that can accommodate viewers in different time zones.
Architecture
Following is the schematic view of an end-to-end setup for delayed live streaming using MediaLive and MediaPackage services on Amazon Web Services (AWS).
- Perform RTP push-based live stream ingest using your preferred tools or software. In this blog post, we use VLC to ingest an RTP push feed to AWS Elemental MediaLive.
- MediaLive generates HLS output and pushes to MediaPackage.
- A MediaPackage channel can expose different origin endpoints for viewers in various time zones. In this post, we generate 3 origin endpoints: one for viewers in India, with a “0” second delay, which means the program base location is India.
- The second origin endpoint is for viewers in Paris, France, with a three hour and thirty minute delay from the current program in India.
- The third origin endpoint is for viewers in Dubai, with a one hour and thirty minute delay from the current program in India.
Steps
Step 1: Create a MediaPackage Channel
- Open the MediaPackage console at https://console.aws.amazon.com/mediapackage/.
- In the navigation pane, under Live, choose Channels.
- On the Channels page, choose Create channel.
- For ID, type a name that describes the channel. The ID is the primary identifier for the channel, and must be unique for your account in the region. For example: timedelay-pkg-channelname or service name.
- For Description, enter any descriptive text that helps you to identify the channel. For example: “Timedelay MediaPackage channel”.
- For Input type, choose Apple HLS.
- Choose Create.
Step 2: Record details of the MediaPackage channel
- Open the MediaPackage console at https://console.aws.amazon.com/mediapackage/.
- In the navigation pane, under Live, choose Channels.
- Select the created MediaPackage channel. In this case “timedelay-pkg-channel”
- From the HLS ingest endpoint section in the Ingest/Origin pane, record the URL, Username, and password.
Step 3: Create MediaLive channel input – RTP push input
- Sign in to the AWS Management Console and open the MediaLive console at https://console.aws.amazon.com/medialive/.
- In the navigation pane, choose Inputs.
- On the Inputs page, choose Create input.
- In the Input details section, for Input name, enter “RTP Push Input”.
- For Input type, choose RTP.
- In the Input security group section, choose Create.
- In the text box, enter the address as a CIDR block. Say 0.0.0.0\0 to allow all traffic.
- Choose Create input security group.
- Choose Create to create the input.
Step 4: Create MediaLive channel from a template
- Open the MediaLive console at https://console.aws.amazon.com/medialive/.
- In the navigation pane, choose Channels. On the Channels page, choose Create channel.
- Enter Channel Name, say “timedelay-ml-channelname or service name”
- For IAM role, select Use existing role and select the role listed. In the case of no existing role, please select Create role from template.
- On the Create channel page, in the Channel and input details section, in the Channel template section, do one of the following:
- To use a built-in template: For Template, from the Channel templates section of the drop-down list, choose Live event HLS template.
- You would see the output group for HLS is auto created with specific output settings.
- On the Create channel page, in the navigation pane, for Input attachments, choose Add.
- In Attach input, for Input, RTP Push Input (the input that you created).
The Attachment name field is automatically populated with the name of the input itself. You can leave this name as is.
- Choose Confirm.
- In HLS output destination, enter the URL captured in Step 2.
- In HLS output destination, credentials option, select Create parameter and enter the Username captured in Step 2 against Username Enter the Name of your choice and enter the Password captured in Step 2 in Password field.
- Choose Create channel
Step 5: Create MediaPackage origin endpoints
- Open the MediaPackage console at https://console.aws.amazon.com/mediapackage/.
- In the navigation pane, under Live, choose Channels.
- Select the created MediaPackage channel.
- On the details page for the channel, under Origin endpoints, choose Manage endpoints.
- We will create three origin endpoints for three time zones (IST, CEST, GST considering IST is the base timezone and time delay configured accordingly for other time zones GST and CEST.)
- Create the origin endpoint for IST
- For ID, enter a name that describes the endpoint. The ID is the primary identifier for the endpoint and must be unique to your account in the AWS Region. Say “IST_EP”.
- For Description, enter any descriptive text that helps you to identify the endpoint. Say “Origin endpoint for India”.
- For Manifest name, enter a short string that will be appended to the end of the endpoint URL. The manifest name helps to create a unique path to this endpoint. Say “ind_ep_index”.
- For Time delay, enter the duration (in seconds) to delay when content is available to players. For IST, set the duration as “0”.
- Choose Add to add one more origin endpoint.
- Create origin endpoint for CEST:
- For ID, enter a name that describes the endpoint. The ID is the primary identifier for the endpoint and must be unique to your account in the AWS Region. Say “CEST_EP”.
- For Description, enter any descriptive text that helps you to identify the endpoint. Say “Origin endpoint for Paris/France”.
- For Manifest name, enter a short string that will be appended to the end of the endpoint URL. The manifest name helps to create a unique path to this endpoint. Say “fra_ep_index”.
- For Time delay, enter 12600 (in seconds) to delay and align the content with the CEST time zone.
- Choose Add to add one more origin endpoint.
- Create origin endpoint for UAE:
- For ID, enter a name that describes the endpoint. The ID is the primary identifier for the endpoint and must be unique to your account in the AWS Region. Say “UAE_EP”.
- For Description, enter any descriptive text that helps you to identify the endpoint. Say “Origin endpoint for Dubai”.
- For Manifest name, enter a short string that will be appended to the end of the endpoint URL. The manifest name helps to create a unique path to this endpoint. Say “ae_ep_index”.
- For Time delay, enter 5400 (in seconds) to delay and align the content with the UAE time zone.
- Choose Save
Step 6: Start MediaLive Channel
- Open the MediaLive console at https://console.aws.amazon.com/medialive/.
- In the navigation pane, choose Channels, and then on the Channelspage, choose the channel that you want to start.
- Choose Start. The channel state changes to one of the following:
- Starting
- Running (encoding on the pipeline or pipelines)
- Choose the channel name. The details for the channel appear.
Step 7: Ingest to MediaLive
- Set up VLC as a contribution encoder using RTP push
- Open the VLC application and select File and then Convert/Stream.
- Drag and drop the video you would like to ingest.
- Select Stream from Choose Destination
- Select Setup Steaming… option
- Select RTP against stream destination Type
- Enter the RTP Address and Port created in Step 3
- Select Apply, to start contribution using VLC
Step 8: Preview all the origin endpoints
- Open the MediaPackage console at https://console.aws.amazon.com/mediapackage/.
- In the navigation pane, under Live, choose Channels.
- Select the created MediaPackage channel.
- On the details page for the channel, under Manage endpoints, select the Preview against each origin endpoint to view the live stream in a delayed fashion.
Step 9: Clean up
Remember to stop the MediaLive streaming channel when you are not using it. This stops the channel from incurring costs when inactive. To delete the channel permanently, stop and delete the MediaLive channel and its associated inputs, then delete the MediaPackage channel as well.
Learn more
AWS provides a number of services designed to assist in the building of media-related workflows. Explore additional applications for video streaming, processing, and delivery using AWS Media Services.