AWS for M&E Blog

Optimizing Amazon IVS live-to-VOD with live input interruptions

Amazon Interactive Video Service (Amazon IVS) has launched “merge fragmented streams” as an enhancement to its Auto-Record to Amazon S3 functionality. This resiliency feature is designed to automatically consolidate multiple recordings together following interruptions to a broadcast’s input stream and address challenges posed where streamers may encounter a variety of networking conditions.

In order to explain the details of this capability, and to understand the benefits to users, we first need to examine how Amazon IVS instantiates live channels and how Auto-Record to Amazon S3 functions. Amazon IVS is a fully managed end-to-end video delivery service, optimized for live streaming and interactivity. One of the core benefits is the abstraction from underlying infrastructure to focus developers on building applications. Customers may create channels in advance until credentialed source streams start or via service APIs and Amazon Web Services (AWS) SDKs. Streamers simply start broadcasting video and the Amazon IVS channel goes live.

When Amazon IVS detects an input stream for a given channel, it generates a unique Session ID. This ID is included in service events and stream health metrics so customers can monitor usage and visualize usage patterns. When record to Amazon S3 is enabled on a channel, Amazon IVS includes the Session ID as part of the asset’s object key to ensure uniqueness, given channels can be reused over time. In a scenario where a streamer’s video is interrupted for a period of time, Amazon IVS may interpret the loss of input as the end of the session and stop the channel. In this case, when the stream is reestablished, Amazon IVS will start the channel again, with a new Session ID. The output will continue to be available on the same, channel-specific playback URL. The VOD recording, however, will be split across different objects; one for the Session ID prior to interruption and one for the Session ID after. Customers have previously worked around this by using channel start/stop events to drive their own detection logic and VOD concatenation process.

Amazon IVS can now manage this on your behalf. If the input to the channel is disrupted and returns within a configurable time window, Amazon IVS can automatically merge the recordings into a single asset, as depicted in the following diagram.

Flow diagram showing content source coming from a Streamer with three parts of the stream separated by two transmission interruption events. The Record to S3 process shows the three parts merged into a single asset when using the new Merge Fragmented Streams feature.

In this example, two input interruptions occur within an hour-long live event. Using the optional “merge fragmented streams” capability, a single, merged asset is recorded to Amazon S3, rather than three distinct parts of the recording.

Configuring asset merging

The Amazon IVS Console and APIs now include a Merge fragmented streams option within a Recording Configuration. When enabled, customers can define a reconnection window between 1 and 300 seconds. If the input stream is disrupted for a duration less than the specified time, Amazon IVS will merge the VOD recordings into a single playable asset. Note that there are use cases where this operation would not apply. Please see the Unsupported Use Case section later in this post.

Amazon IVS Recording configuration

Anatomy of a merged stream

Amazon IVS “merges” streams by keeping the recording session open for the duration of a user-specified “reconnect window” during a live input interruption, before an asset is finalized using an ENDLIST HLS tag. A DISCONTINUITY tag is inserted at the point where the sessions merge to signal to the player that something has changed.

The following example shows a section of a playlist manifest across an input interruption. Input is lost partway through segment 28. Input returns within the configured reconnection window, Amazon IVS adds a DISCONTINUITY tag, then continues from segment 30 onwards.

#EXTINF:10.833,
26.ts
#EXTINF:10.633,
27.ts
#EXTINF:8.474,
28.ts
#EXT-X-DISCONTINUITY
...
#EXTINF:10.500,
30.ts
#EXTINF:10.233,

Monitoring with Amazon EventBridge

Amazon IVS produces events showing the various states of a channel’s operation, using Amazon EventBridge. The message sequence diagram that follows shows typical messages for Amazon IVS channels that have a recording configuration defined with merge fragmented streams enabled, and the various events that are created as a result of an input interruption. The “Recording Start” and “Recording End” events are highlighted.

The event message sequence diagram shows the various states that an IVS channel progresses through, including events around recordings with the Merge Fragmented Streams function enabled: Session Create - Session Start - Recording Start - Session End - Stream End - Session Create - Stream Start - Stream End - Session End - Recording End (showing multiple Stream ID’s, corresponding to the merge operation)

When starting an Amazon IVS channel, the Session Create and Stream Start events are triggered, and Amazon IVS sends the Recording Start. We can obtain key details of the recording in the Recording event messages, including the address of the recording can be obtained through: recording_s3_bucket_name + recording_s3_key_prefix

Two new fields, “recording_session_id” and “recording_session_stream_ids“, have been added to the Recording State Change events published through EventBridge with the addition of the merge fragmented streams capability. The “recording_session_id” field is now available in all Recording events, allowing customers to map recordings and sessions together. The “recording_session_stream_ids” field has been added to Recording End/Recording End Failed events. This field contains all the stream IDs that were “merged” into a single recording. This field can be used to find all streams for a recording. If no merging occurred, the length of this list array is 1.

Refer to the user guide for further information on using EventBridge with Amazon Interactive Video Service.

Unsupported use case

If Amazon IVS detects a change in the stream format between different sessions, such as resolution (e.g., from Full HD to HD) or a significant variation in the video bitrate, the service will interpret this as a new broadcast session. Amazon IVS will not merge the streams, even when consecutive sessions fall within the “reconnect window” interval. You can obtain input format details through the stream health dashboard or programmatically via the GetStreamSession API.

Get started now using merge fragmented streams for Amazon IVS

The merge fragmented streams capability enhances the Auto-Record to Amazon S3 functionality, allowing developers to simplify their VOD workflows. Stream sessions are consolidated in a single media recording, so viewers can re-watch the content without any interruptions that may have occurred during the live stream due to network instabilities or other stream disruptions.

Osmar Bento

Osmar Bento

Osmar Bento is a Senior Solution Architect specializing in Direct-to-Consumer experiences for M&E, Gaming, and Sports at AWS. Osmar collaborates with customers to innovate and create tailored solutions using the AWS platform, enhancing their media and entertainment operations.

Christer Whitehorn

Christer Whitehorn

Christer is the Lead Solutions Architect specializing in AWS Media Services for the Asia Pacific region including Japan and Greater China. He has spent more than twenty years working with multiscreen video, broadcast playout and compression headend solutions.