All Products
Search
Document Center

Object Storage Service:Playlist generation

Last Updated:May 29, 2025

Live transcoding allows videos to be dynamically transcoded and instantly played by creating M3U8 playlists for HTTP live Streaming (HLS), without the need to create transport stream (TS) objects in advance. Compared with traditional transcoding, live transcoding considerably shortens the time required to begin transcoding videos, and greatly reduces transcoding and storage overheads due to the on-demand capabilities.

Overview

Unlike Video transcoding, which requires the entire video to be transcoded before playback can begin, live transcoding processes only the necessary video segments and allows playback to start immediately after the original video file is uploaded. Live transcoding offers the following benefits:

  • Instant playback during transcoding and no buffering.

  • Optimized transcoding and smooth playback with scrubbing completed in seconds

  • On-demand transcoding, re-transcoding in case of deletion of transcoded files, and reduced transcoding and storage costs.

  • Custom transcoding with dozens of custom transcoding parameters.

  • Good compatibility with more than 300 audio and video formats.

Scenarios

  • Play videos stored in network drives: Live transcoding allows videos in network drives to be instantly played upon request on clients at resolutions that best suit actual network conditions. This ensures real-time playback and provides good video compatibility across devices. Live transcoding also reduces storage costs because videos in network drives are not transcoded if the videos are not requested.

  • Videos stored in network drives: When users upload videos to a network drive, the optimal playback resolution is automatically selects by the client based on real-time network conditions, ensuring both real-time playback and multi-device compatibility. Cold Archive videos are not transcoded if not played, effectively reducing storage costs.

  • Preview and play videos on social media platforms: Live transcoding allows users on instant messaging and social media platforms to immediately play received videos. This improves the timeliness of communications. In addition, when users play videos in chat history that remain unwatched for an extended period of time, they can still be played instantly even if TS objects generated for the videos are regularly cleared to reduce storage usage.

  • Preview of the videos on social media platforms: Videos shared via instant messaging or social meida platforms become playable immediately upon delivery, eliminating wait times. Unwatched videos in chat history remain instantly accessible even after periodic cleanup of TS segments (used to optimize storage utilization).

  • Share video content on forums and blogging platforms: Live transcoding provides users on forums and blogging platforms with a smooth, device-compatible video viewing experience. It allows users to immediately play shared videos at the resolution that best suits their network conditions, without the need to wait for video transcoding.

  • Videos shared on forums & blogs : Live transcoding technology, enables users to start playback without waiting for full transcoding. This ensures smooth and clear playback.

Features

The following table describes the benefits of live transcoding in detail.

Feature

Description

Standardization

  • Live transcoding supports the HTTP Live Streaming (HLS) protocol.

  • Live transcoding supports media playlists and master playlists.

  • Live transcoding enables playback of videos with multiple video streams, audio streams, and subtitle streams.

  • Live transcoding supports mainstream HLS players.

  • Live transcoding supports more than 300 mainstream audio and video formats.

Cost-efficiency

  • Videos and video segments that are not played are not transcoded, which reduces transcoding overhead.

  • Transcoded video segments can be deleted to reduce storage usage. Playing videos whose transcoded video files or segments have been deleted triggers transcoding again, without affecting the online playback experience.

High efficiency

  • IMM adopts a large server cluster and therefore supports large numbers of live transcoding tasks.

  • Videos can be converted into video streams with different resolutions and bitrates to ensure smooth playback in different network conditions.

  • Viewers can play videos immediately when playlists are generated, without the need to wait for videos to be entirely transcoded.

  • The video header segment size is adaptive, making video loading more efficient.

  • Intelligent pre-transcoding is supported.

Supported audio and video formats

The live transcoding feature supports virtually all audio and video formats, encompassing over 300 different types. The following table describes some common audio and video formats supported by live transcoding.

Input video formats

AVI, MOV, FLV, MKV, WebM, MPEG, WMV, RM, VOB, and TS, all mainstream video formats

Input audio formats

MP3, WAV, AAC, FLAC, and WMA, all mainstream video formats

Output container format

TS

Prerequisites

  • IMM is activated. For more information, see Activate IMM.

  • Before proceeding, make sure that an IMM Project is mapped to your bucket. For more information about how to map an IMM Project, see Get started and AttachOSSBucket. For more information about how to map an IMM Project in the OSS console, see Get started. For more information about how to map an IMM Project by calling an API operation, see AttachOSSBucket.

  • IMM is granted the permissions that are required to perform the operation. For more information, see Permissions.

Usage notes

Parameters

Action: hls/m3u8

The following table describes the parameters that you can configure to generate live transcoding playlists.

Parameter

Type

Required

Description

ss

int

No

The point in time at which the playlist generation begins in the source video. Unit: milliseconds. Valid values:

  • 0: The playlist generation begins at the starting position of the source video. This is the default value.

  • An integer greater than 0: The playlist generation begins at the specified number of milliseconds in the source video.

Note

You can use this parameter together with the t parameter to generate a playlist that covers only a portion of the video content.

t

int

No

The duration of the content in the source video covered by the playlist. Unit: milliseconds. Valid values:

  • 0: The playlist extends to the end of the source video. This is the default value.

  • An integer greater than 0: The playlist covers the specified duration of content from the starting position.

Note

If you set this parameter to a value that exceeds the total duration of the source video, the playlist extends only to the end of source video.

ta

int

No

The number of TS objects to be pre-transcoded when live transcoding is triggered. By default, a 2-minute segment is pre-transcoded.

For example, if you set the st parameter to 10000, the default value of the ta parameter is 12. Valid values: 10 to 30.

st

int

No

The duration of a TS object. Unit: milliseconds. Default value: 10000. Valid values: 5000 to 15000.

initd

int

No

The duration covered by initial transcoding. Unit: milliseconds. Default value: 30000.

  • If you set this parameter to 0, no initial transcoding applies.

  • If you set this parameter to a value that is less than 0 or greater than the duration of the source video, initial transcoding covers the entire duration of the source video.

  • If you set this parameter to a value that falls within the duration of a TS object, initial transcoding extends to the end of the TS object.

Note

This parameter reduces the time required to start the first playback, which enhances the viewing experience. If you want to use live transcoding in traditional video-on-demand scenarios, you can initially transcode entire videos.

vcodec

string

No

The coding format of the output video. Valid values:

  • h264 (default)

  • h265

fps

float

No

The target frame rate. By default, the target frame rate is the same as the source frame rate.

fpsopt

int

No

The frame rate option. Valid values:

  • 0: always uses the target frame rate.

  • 1: uses the source frame rate when the source frame rate is less than the target frame rate. This is the default value.

  • 2: returns a failure when the source frame rate is less than the target frame rate.

Note

This parameter must be used together with the fps parameter.

pixfmt

string

No

The pixel format. By default, the pixel format matches that of the source video. Valid values:

  • yuv420p

  • yuv422p

  • yuv444p

  • yuv420p10le

  • yuv422p10le

  • yuv444p10le

s

string

No

The target resolution in the WidthxHeight format. By default, the target resolution is the same as the source resolution.

  • The resolution is in the WidthxHeight format.

  • The width and height must be a multiple of 2 and within the range of 64 to 4,096. Examples: 4096x4096 and 64x64.

sopt

string

No

The resolution option. Valid values:

  • 0: always uses the target resolution.

  • 1: uses the source resolution when the source resolution is less than the target resolution.

  • 2: returns a failure when the source resolution is less than the target resolution.

scaletype

string

No

The resizing mode. Valid values:

  • stretch: forcibly stretches the video based on the specified width and height or long edge and short edge to fill the remaining space. This is the default value.

  • crop: proportionally resizes the video to the minimum resolution outside the rectangular shape based on the specified width and height or long edge and short edge, and crops the parts beyond the rectangular shape from the center.

  • fill: proportionally resizes the video to the maximum resolution within the rectangular shape based on the specified width and height or long edge and short edge, and fills the empty space with black from the center.

  • fit: proportionally resizes the video to the maximum resolution within the rectangular shape based on the specified width and height or long edge and short edge.

Note

This parameter must be used together with the s parameter.

arotate

int

No

Specifies whether to enable adaptive resolution orientation. Valid values:

  • 0: disables adaptive resolution orientation. This is the default value.

  • 1: enables adaptive resolution orientation.

vb

int

No

The target video bitrate. Unit: bit/s.

If you leave both the crf and vb parameters empty, the crf parameter is set to 23 by default. If you specify the vbopt parameter, you must also specify the vb parameter.

vbopt

int

No

The video bitrate option. Valid values:

  • 0: always uses the target video bitrate.

  • 1: uses the source video bitrate when the source video bitrate is less than the target video bitrate. This is the default value.

  • 2: returns a failure when the source video bitrate is less than the target video bitrate.

crf

float

No

The constant rate factor (CRF). The value of this parameter falls within the [0,51] range. A greater value indicates lower quality. We recommend that you specify a value within the [18,38] range. This parameter and the vb parameter are mutually exclusive. If you leave both the crf and vb parameters empty, the crf parameter is set to 23 by default.

maxrate

int

No

The maximum bitrate if the dynamic bitrate is used. If you specify this parameter, you must also specify the bufsize parameter.

Note

This parameter must be used together with the crf parameter.

bufsize

int

No

The size of the buffer in dynamic bitrate mode. Unit: bit/s.

Note

This parameter must be used together with the crf parameter.

an

int

No

Specifies whether to disable audio stream generation. Valid values:

  • 0: does not disable audio stream generation. This is the default value.

  • 1: disable audio stream generation.

acodec

string

No

The audio coding format. Valid value: acc.

ar

int

No

The sampling rate of the output audio. Unit: Hz. By default, the sampling rate of the source audio is retained. Valid values:

  • 8000

  • 11025

  • 12000

  • 16000

  • 22050

  • 24000

  • 32000

  • 44100

  • 48000

  • 88200

  • 96000

ac

int

No

The number of sound channels. By default, the output audio has the same number of sound channels as the source audio. Valid values: [1,8].

aq

int

No

The audio quality. The value of this parameter falls within the range of 0 to 100. A greater value indicates higher audio quality. This parameter and the ab parameter are mutually exclusive.

ab

int

No

The target audio bitrate. Unit: bit/s. This parameter and the aq parameter are mutually exclusive. Valid values: 1000 to 10000000.

abopt

int

No

The audio bitrate option. Valid values:

  • 0: always uses the target audio bitrate.

  • 1: uses the source audio bitrate when the source audio bitrate is less than the target audio bitrate. This is the default value.

  • 2: returns a failure when the source audio bitrate is less than the target audio bitrate.

Note

You may also need to use the sys/saveas parameter when you generate a playlist. For more information, see sys/saveas.

Use the RESTful API

To use live transcoding, perform the following steps:

Note

After a playlist is generated, you can also follow the instructions in the Live transcoding topic of the IMM documentation to play the video.

1. Generate a playlist

Transcoding task information

  • Before transcoding

    • Video format: AVI

    • Video name: oss://video-demo/example.avi

    • Starting position for transcoding: the 15th second of the video

    • Duration to be transcoded: 1,800 seconds

  • Processing method: Generate a playlist.

  • After transcoding

    • Segment duration: 10 seconds

    • Pre-transcoded video duration: 30 seconds

    • Video information

      • Video stream format: H.264

      • Video resolution: 1280 × 720

      • Frame rate: 25 fps

      • Video bitrate: 2 Mbit/s

    • Audio information

      • Audio stream format: AAC

      • Audio bitrate: 128 Kbit/s

    • Path prefix: oss://outbucket/outobjprefix/media

Sample request

POST /example.avi?x-oss-process HTTP/1.1
Host: video-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e

x-oss-process=hls/m3u8,ss_15000,t_1800000,vcodec_h264,fps_25,fpsopt_1,s_1280x720,sopt_1,scaletype_fit,arotate_1,vb_2000000,vbopt_1,acodec_aac,ar_44100,ac_2,ab_128000,abopt_1,st_10000,initd_30000|sys/saveas,o_b3V0b2JqcHJlZml4L21lZGlh,b_b3V0YnVja2V0

Sample response

HTTP/1.1 200 OK
Server: AliyunOSS
Date: Wed, 25 May 2022 12:43:57 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 161
Connection: keep-alive
x-oss-request-id: 628E2481184E20F26C000009
x-oss-transfer-acc-type: acc-none
x-oss-data-location: oss-cn-hangzhou-a
ETag: "D0F162350DA037F4DC2A142B2E116BD0"
Last-Modified: Wed, 25 May 2022 12:20:34 GMT
x-oss-object-type: Normal
x-oss-hash-crc64ecma: 2040549661341440100
x-oss-storage-class: Standard
x-oss-server-time: 12437

{"Duration":1800,"RequestId":"********-37E6-5996-8425-********","VideoPlaylist":[{"FrameRate":"25","Resolution":"1280x720","Token":"f93c43079**********1269608ebc86e","URI":"oss://outbucket/outobjprefix/media.m3u8"}]}

2. Use hls/sign to sign TS objects

OSS provides a dynamic signature mechanism for accessing audio and video data. You must add the x-oss-process=hls/sign,live_1 parameter to the URL of an M3U8 playlist the first time you access the M3U8 playlist. Then, OSS automatically signs the URLs of all TS objects in the M3U8 playlist by using the same signing method that is used to sign the M3U8 playlist.

  • The following sample code provides an example on how to sign an M3U8 playlist by using hls/sign:

# -*- coding: utf-8 -*-
import os
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider

# Specify the endpoint for the region in which the bucket is located.  
endpoint = 'yourEndpoint'

# Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. 
auth = oss2.ProviderAuth(EnvironmentVariableCredentialsProvider())
# Specify the name of the bucket in which the generated playlist is stored. 
bucket_name = 'your-oss-bucket-name'
# Specify the name of the playlist. 
key = 'output/media.m3u8'

# Specify the bucket instance. You must use the bucket instance to call all object-related methods. 
# The oss2.AuthV2 signature method must be used. 
bucket = oss2.Bucket(auth, 'https://oss-cn-hangzhou.aliyuncs.com', bucket_name)

# Specify hls/sign,live_1 in the x-oss-process operation. 
params = {}
params.update({oss2.Bucket.PROCESS: 'hls/sign,live_1'})

# Sign the URL. 
# By default, OSS identifies forward slashes (/) in the full path of an object as escape characters in the signing process. Therefore, the signed URL cannot be directly used. 
# Set the slash_safe parameter to True. This way, OSS does not identify the forward slashes (/) in the full path of the object as escape characters, and the signed URL can be directly used. 
url = bucket.sign_url('GET', key, 7200, params=params, slash_safe=True)

# The generated URL can be directly used in an HLS player for playback. 
print(url)
  • The following content provides an example of an original M3U8 object:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:10.0,
media-c14709808479b31566b50f2f8b93fe1a-0.ts
#EXTINF:10.0,
media-c14709808479b31566b50f2f8b93fe1a-1.ts
#EXTINF:10.0,
media-c14709808479b31566b50f2f8b93fe1a-2.ts
#EXTINF:10.0,
media-c14709808479b31566b50f2f8b93fe1a-3.ts
#EXT-X-ENDLIST
  • The following content provides an example of a signed version of the M3U8 object:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:10.000,
media-c14709808479b31566b50f2f8b93fe1a-0.ts?x-oss-process=if_status_eq_404{hls/ts,from_b3V0cHV0L21lZGlhLm0zdTg}&x-oss-expires=1710457284&x-oss-signature-version=OSS2&x-oss-access-key-id=****fEAub****&x-oss-signature=****VR3gy****
#EXTINF:10.000,
media-c14709808479b31566b50f2f8b93fe1a-1.ts?x-oss-process=if_status_eq_404{hls/ts,from_b3V0cHV0L21lZGlhLm0zdTg}&x-oss-expires=1710457284&x-oss-signature-version=OSS2&x-oss-access-key-id=****fEAub****&x-oss-signature=****VR3gy****
#EXTINF:10.000,
media-c14709808479b31566b50f2f8b93fe1a-2.ts?x-oss-process=if_status_eq_404{hls/ts,from_b3V0cHV0L21lZGlhLm0zdTg}&x-oss-expires=1710457284&x-oss-signature-version=OSS2&x-oss-access-key-id=****fEAub****&x-oss-signature=****VR3gy****
#EXTINF:10.000,
media-c14709808479b31566b50f2f8b93fe1a-3.ts?x-oss-process=if_status_eq_404{hls/ts,from_b3V0cHV0L21lZGlhLm0zdTg}&x-oss-expires=1710457284&x-oss-signature-version=OSS2&x-oss-access-key-id=****fEAub****&x-oss-signature=****VR3gy****
#EXT-X-ENDLIST

Use OSS SDKs

Playlist generation is a synchronous operation. For more information about how to generate a playlist by using OSS SDKs, see Use OSS SDKs.

FAQ

What are the output objects of a playlist generation operation?

The output objects of a playlist generation operation include M3U8 and TS objects. M3U8 objects are immediately generated. The specified number of pre-transcoded TS objects are asynchronously generated. The portion of the video that is not pre-transcoded is asynchronously transcoded only if a playback of the portion is requested. For example, if a video was not played, no TS objects are generated for the portion that is not included within the range of pre-transcoding. If pre-transcoding does not cover the 15th minute of a video, and you play the video from the 15th minute, transcoding starts from the 15th minute. The following content provides sample output objects of a playlist generation operation:

.
├── outobjprefix.m3u8
├── outobjprefix-92376fbb-171f-4259-913f-705f7ee02f2s-0.ts
├── outobjprefix-92376fbb-171f-4259-913f-705f7ee02f2s-1.ts
├── outobjprefix-92376fbb-171f-4259-913f-705f7ee02f2s-2.ts
├── outobjprefix-92376fbb-171f-4259-913f-705f7ee02f2s-3.ts

Can I play a video whose TS objects are deleted?

Yes, you can play the video even if some or all TS objects are deleted. However, make sure that the video and M3U8 object are not deleted. This is because a request for the M3U8 playlist triggers the regeneration of TS objects. This mechanism allows you to delete TS objects generated for videos that remain unwatched for an extended period of time to reduce storage costs without affecting future playback performance.

Does live transcoding support M3U8 playlists that are not created from live transcoding?

No, live transcoding does not support M3U8 playlists that are not created from live transcoding.