This topic describes the live packaging feature of MediaPackage.
Overview
Live packaging allows you to package the live stream content, formatting it in response to playback requests from downstream devices. Live packaging can be used together with the time shifting feature, which lets viewers replay live content as if it were a video-on-demand (VOD) resource, for example, during a live sports game. You can also store live content in Object Storage Service (OSS).
You are charged fees for using live packaging.
Configure the feature
To use live packaging, create a packaging configuration.
Log on to the Intelligent Media Services (IMS) console. In the upper-left corner, select a region based on your business requirements.
In the left-side navigation pane, choose
. On the page that appears, click Create Channel Group.Parameter
Description
Channel Group Name
Enter a custom name.
Description
Enter a custom description.
NoteChannel groups and channels created for this feature are not related to the channel assembly feature of MediaWeaver.
After you create a channel group, an origin domain name is automatically assigned to it.
On the Live Package page, click the channel group that you created. On the channel group details page, click Create Channel.
Parameter
Description
Channel Name
Enter a custom name.
Protocol
The protocol of the source stream. Only HTTP Live Streaming (HLS) is supported.
Maximum Segment Length
The duration of a single segment in a packaged stream.
We recommend that you set the value to 6. Avoid specifying a too large or too small value.
A larger value increases the content of a single segment but also increases latency.
A smaller value decreases the content of a single segment but indirectly increases the number of requests, leading to higher resource overhead.
Segments
The number of segments included in an M3U8 file that is returned when a packaged stream is played.
We recommend that you set the value to 3. A larger value extends the timeline of a live stream on the player, and also increases the traffic and latency.
Click the channel that you created. On the channel details page, click the Endpoints tab, then click Create Endpoint.
Parameter
Description
Protocol
The playback protocol. Only HLS is supported.
Manifest Name
The manifest name. For example, if you specify "index", the playback URL is https://example.aliyundoc.com/index.m3u8.
Authorization Code
If you configure this parameter, the content requests from a player or a content delivery network (CDN) to this endpoint must include the Authorization header whose value is set to the authorization code. For information about how to configure request headers for origin requests by using Alibaba Cloud CDN, see Configure HTTP request headers.
IP Address Whitelist
IPv4 and IPv6 addresses and subnet masks are supported.
IP Address Blacklist
IPv4 and IPv6 addresses and subnet masks are supported.
Startover Window
If you set this parameter to a value greater than 0, time shifting is enabled. Time shifting allows viewers to replay live content as if it were a VOD resource. For more information about time-shifted viewing, see Time-shifted viewing.
You can use the Live-to-VOD feature to run a collection task for the endpoint only if time shifting is enabled. The collection task is used to store live content in OSS.
After the endpoint is created, a playback URL of the packaged stream is generated. You can find the playback URL in the URL column of the endpoint on the Endpoints tab.
Use the feature
Stream ingest
For each channel that is created, input URLs and keys are generated. To view them, go to the Input tab of the channel details page.
ingest1: the primary input URL.
ingest2: the secondary input URL.
Click Authentication to obtain the account name and password.
A channel provides primary and secondary input URLs to receive two identical HLS streams from an upstream encoder. If one input URL encounters issues, the channel switches to the other one. This improves channel availability.
Sample URL:
http://xxxxxx-1.packagepush-9eji12.ap-southeast-1.ice.aliyundoc.com/v1/dfjtest/1/test01/manifest
To send the live streams from an upstream encoder to MediaPackage, specify the input URLs of the channel as the output of the encoder. Use Basic Auth for authentication and use the PUT method to upload M3U8 and transport stream (TS) files. The request URLs for these files must be prefixed with one of the input URLs.
Examples:
http://xxxxx-1.packagepush-9eji12.ap-southeast-1.ice.aliyundoc.com/v1/dfjtest/1/test01/manifest.m3u8
http://xthcfa-1.packagepush-9ejigb.ap-southeast-1.ice.aliyundoc.com/v1/dfjtest/1/test01/manifest-hd-1001.ts
Notes:
To use Basic Auth, add "Authorization: Basic BASE64_ENCODE(username:password)" as a request header.
To comply with live streaming standards, upload master playlists, media playlists, and TS segments that are valid. Encrypted HLS streams are not supported.
If you ingest an active stream and a standby stream, make sure that the two streams have the same content with aligned timestamps. Otherwise, smooth playback cannot be ensured during switchover of the two streams.
We recommend that you use MediaLive as the upstream encoder. For more information, see Media Live Streaming Overview.
Playback
Use the playback URL that was generated when you created an endpoint to play the packaged stream.
For debugging, you can add private IP addresses to the IP address whitelist of the endpoint or configure the Authorization request header for the player, with the value of the header set to the authorization code of the endpoint.
If you want to allow an external user to play the packaged stream, we recommend that you configure CDN authorization to accelerate delivery and protect your content from unauthorized use. You need to configure your CDN to include the Authorization header in content requests to MediaPackage, with the value of the header set to the authorization code of the endpoint. If you need help with CDN configuration, contact your CDN provider.
Time-shifted viewing
If time shifting is enabled, live packaging stores live segments in OSS. Viewers can initiate requests to replay live content.
Sample request:
https://xxxxx-1.packagepush-9eji12.ap-southeast-1.ice.aliyundoc.com/v1/group01/ch01/endpoint01/index.m3u8?start=2024-11-06T00:00:00Z&vodend=2024-11-06T02:00:00Z
In this example, the live content from 2024-11-06T00:00:00Z to 2024-11-06T02:00:00Z is replayed. The request URL is actually the playback URL of an endpoint appended with two extra parameters: start and vodend. start indicates the start time of time-shifted viewing, while vodend indicates the end time.
The following table describes the parameters supported by requests for time-shifted viewing:
Parameter | Description |
start | The start time of time-shifted viewing. The time is displayed in UTC at the GMT+0 time zone. Example: 2024-11-06T00:00:00Z. |
end | The end time of time-shifted viewing in live mode. The time is displayed in UTC at the GMT+0 time zone. Example: 2024-11-06T02:00:00Z. |
vodend | The end time of time-shifted viewing in VOD mode. The time is displayed in UTC at the GMT+0 time zone. Example: 2024-11-06T02:00:00Z. Note In VOD mode, all segments are returned at once and the progress bar of the player can be used to fast forward and backward the video. |
offset | The amount of time by which the live stream is rewound from the current time of request. Unit: seconds. This parameter determines the start point of time-shifted viewing. Example:
|
Usage notes:
You must specify either
start
oroffset
.If both
end
andvodend
are specified,vodend
takes precedence.
Create a collection task
You can run collection tasks to store live content in OSS for later playback.
Prerequisites
OSS is activated, and at least one bucket is created to store the files of live streams. For more information, see Activate OSS and Create a bucket. Make sure that the bucket resides in the same region where you use the live packaging feature.
ImportantYou are charged fees for files that are stored in OSS. For more information about OSS storage fees, see Storage Fees.
The time shifting feature is enabled for channel endpoints, with the startover window set to a value greater than 0.
Procedure
In the channel list, click on the name of the channel that you want to use. On the channel details page, click the Collection Task tab and then click Create Collection Task.
Parameter | Description |
Endpoint | Select an endpoint within the channel. You must enable the time shifting feature for the endpoint by setting the startover window to a value greater than 0. |
Collection Time | Live content generated during the collection time is stored in OSS, provided that the time shifting feature is enabled. |
Storage Path | Select the OSS bucket in which the collected M3U8 files are stored. |
A collection task automatically starts after it is created. To view the collected files, go to the OSS console.
If you create multiple collection tasks for an endpoint, separate files are collected for each of the tasks.
FAQs
How do I ingest streams when using the live packaging feature?
You can use an upstream encoder that supports HLS to send live streams to MediaPackage. We recommend that you use MediaLive.
Why are no files collected for a collection task that I created?
Make sure that time shifting is enabled for the endpoint, with the startover window set to a value greater than 0.
What are the differences between creating a collection task from the Live Package and Live to VOD modules in the IMS console?
They are basically the same. You can use either method to implement the Live-to-VOD feature. However, the Live to VOD module lets you manage all collection tasks on one page, whereas the Live Package module lets you manage collection tasks of separate channels.