Every live stream on Mux is automatically recorded as an asset
.
When playing back a live stream, Mux offers you two options for historical playback. Both options are available at any time; you can switch between the two at will.
The 3 Mux concepts we need to understand here are:
stream.mux.com
URL of the form: https://stream.mux.com/{PLAYBACK_ID}.m3u8.
In non-DVR Mode, all users viewing the live stream will be viewing the most recent content. The player will have access to approximately the most recent 30 seconds of content.
In order to use non-DVR mode, construct your playback URL with the playback ID associated with the live stream.
Non-DVR Mode is most common
Most uses of live streaming opt for non-DVR mode and, if you are unsure about which to use, we recommend that you stick with non-DVR mode.
When using DVR mode, the player will have access to your stream's content going all the way back to the beginning of the live stream.
Be careful with DVR Mode and long lived streams
Mux does not recommend DVR mode for live streams longer than four hours. If you expect long live streams, you should use non-DVR mode.
If you choose to use DVR mode, then you should construct your playback URL using the playback ID associated with the live stream's active_asset_id
.
Mux will automatically start creating an asset in the background when you begin broadcasting to your live stream. This asset has two purposes:
Since assets are automatically created from every live stream and live streams can be re-used as many times as you want, Mux creates a new asset every time a live stream begins broadcasting. A single live stream can end up producing an indefinite number of assets.
The lifecycle of events produced by a Mux live stream is as below.
idle
video.live_stream.connected
: The encoder has connected. At this point in time the live stream will have a new active_asset_id
. The active_asset_id
is the ID that points to a new asset that Mux is creating for this live stream.video.asset.created
: The asset corresponding to the active_asset_id
from step 2 gets created. This asset has a live_stream_id
that points back to the live stream it was created from. This asset does not have any content yet, it is a placeholder that will be getting content from the ingested live stream.video.live_stream.recording
: Mux has started recording the incoming content. The live stream's status will still be idle
at this point.video.live_stream.active
: The live stream's state has transitioned active
. When in non-DVR mode, the live stream's playback ID can now be used to build a playback URL on stream.mux.com
.video.asset.ready
: The asset (active_asset_id
) from step 2 and 3 will be "ready" at around the same time that the live stream is "active". This asset only has about 10 seconds worth of content at this point. The duration
on this asset reflects the current playable duration. If you are using DVR mode, it is at this point that you can use the active_asset_id
to build a playback URL on stream.mux.com
.video.live_stream.disconnected
: The encoder has disconnected, and the live stream status is still active
. Please note that live streams that do not use the "latency_mode": "reduced"
option will enter a reconnect window (defaulting to a duration of 60 seconds) after disconnecting. The encoder can re-connect within this reconnect window and, in doing so, pick back up where it left off with the same active_asset_id
. For more information, please consult handling live stream disconnects.video.live_stream.idle
: After the encoder has stayed disconnected for the duration of the reconnect window, the live stream will transition back to status idle
. This live stream will no longer have an active_asset_id
associated with it. The next time an encoder connects this lifecycle with start back at step 1 with a new active_asset_id
.video.asset.live_stream_completed
: This event fires at the same time as the live stream transitions back to idle
. This event tells you that the asset is finalized. The duration
of the asset will now be the full, finalized duration; you can use the playback ID in your player to play the recording of the live stream.Please note that some of these webhook events correspond to the live_stream
resource and others correspond to the asset
.
More information about configuring and using webhooks can be found in the webhooks guide.