All Products
Search
Document Center

Object Storage Service:Generate a live transcoding playlist

Last Updated:Dec 20, 2025

This feature generates a standard HTTP Live Streaming (HLS) m3u8 playlist for a video. This lets you play the video immediately without pre-generating Transport Stream (TS) files. The video is dynamically transcoded as it plays. Compared to traditional offline transcoding, this method significantly reduces transcoding wait times and lowers transcoding and storage costs by processing content on demand.

Introduction

Unlike video transcoding, which requires you to wait for the entire video to be transcoded before playback, live transcoding is a real-time feature. It lets you start playback immediately after the source video file is uploaded by transcoding only the necessary video segments on the fly. Live transcoding provides the following benefits:

  • Transcode during playback, which eliminates waiting time.

  • Optimized transcoding enables fast start-up and seeking, which provides a playback experience similar to local playback.

  • Transcoding does not occur if the video is not played. Transcoded files can be deleted and regenerated on demand. This significantly saves transcoding and storage costs.

  • Supports dozens of transcoding parameters for a high degree of customization.

  • Provides high compatibility with support for over 300 audio and video formats.

Scenarios

  • Network drives: After a user uploads a video, the client can select the optimal resolution for playback based on network conditions. This ensures real-time playback and device compatibility. Videos that are not frequently accessed are not transcoded if they are not played, which reduces storage costs.

  • Video previews in chat applications: In instant messaging or social media applications, a video is playable immediately after it is sent. This improves real-time performance. Videos in chat history can be periodically deleted and remain playable on demand.

  • Online forums and blogs: When you share videos on forums and blogs, live transcoding allows users to watch videos without waiting for transcoding. This ensures smooth playback and high definition.

Features

The following table describes the features of live transcoding.

Feature

Description

Standardization

  • Supports the standard HLS protocol.

  • Supports media playlists and the generation of master playlists.

  • Supports playback of multiple video, audio, and subtitle streams.

  • Supports mainstream HLS players.

  • Supports over 300 mainstream audio and video formats.

Low cost

  • Videos and segments that are not played are not transcoded. This reduces transcoding costs.

  • Transcoded video segments can be deleted to save storage costs. When the video is played again, the system automatically triggers a new transcoding task to ensure a seamless online playback experience.

High efficiency

  • A large-scale cluster supports real-time transcoding.

  • Provides video streams in multiple resolutions and bitrates to adapt to different network environments and ensure smooth playback.

  • Playback can start as soon as the playlist is generated, without waiting for the entire transcoding process to complete.

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

  • Supports intelligent pre-transcoding.

Supported audio and video formats

Live transcoding supports over 300 audio and video formats, including almost all common formats. The following table lists some of the common supported formats.

Input video format

All mainstream formats, such as AVI, MOV, FLV, MKV, WebM, MPEG, WMV, RM, VOB, and TS.

Input audio format

All mainstream formats, such as MP3, WAV, AAC, FLAC, and WMA.

Output container format

TS

Prerequisites

Usage notes

Parameter description

Operation: hls/m3u8

The following table describes the parameters.

Parameter

Type

Required

Description

ss

int

No

The start time for generating the playlist. Unit: milliseconds (ms). Valid values:

  • 0 (default) or empty: starts from the beginning of the source video.

  • A value greater than 0: starts from the specified time in the source video.

Note

Use this parameter with the t parameter to generate a playlist for a specific part of the source video.

t

int

No

The transcoding duration for the playlist. Unit: ms. Valid values:

  • 0 (default) or empty: continues to the end of the source video.

  • A value greater than 0: continues for the specified duration from the start time of playlist generation.

Note

If the specified time exceeds the end of the source video, the default value is used.

ta

int

No

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

Example: If st is 10000, the default value of ta is 12. You can specify this parameter to control the number of asynchronous pre-transcoded segments. Valid values: [10,30].

st

int

No

The duration of a single TS file segment. Unit: ms. Default: 10000. Valid values: [5000,15000].

initd

int

No

The duration of the initial transcoding when the playlist is generated. Unit: ms. Default: 30000.

  • If the duration is 0, no pre-transcoding is performed.

  • If the value is negative or exceeds the source video duration, the entire video is initially transcoded.

  • If the specified duration falls in the middle of a TS file, transcoding continues to the end of that TS file.

Note

This parameter is mainly used to reduce the waiting time for the first playback and improve the user experience. To replace a traditional VOD service, you can try to initially transcode the entire video.

vcodec

string

No

The video codec (encoding format). Valid values:

  • h264 (default): H.264 encoding format.

  • h265: h265 encoding format.

fps

float

No

The video frame rate. Default: same as the source video.

fpsopt

int

No

The video frame rate option. Valid values:

  • 0: Always use the target frame rate.

  • 1 (default): Use the source frame rate if it is lower than the value of fps.

  • 2: Return an error if the source frame rate is lower than the value of fps.

Note

This parameter must be set together with the fps parameter.

pixfmt

string

No

The pixel format. Default: same as the source video. Valid values:

  • yuv420p

  • yuv422p

  • yuv444p

  • yuv420p10le

  • yuv422p10le

  • yuv444p10le

s

string

No

The resolution of the output video, in width × height format. Default: same as the source video resolution.

  • The format is w × h, which means width × height.

  • The width and height must be multiples of 2 and range from 64 to 4096. For example: 4096 × 4096, 64 × 64.

sopt

string

No

The resolution option. Valid values:

  • 0: Always use the specified target video resolution.

  • 1 (default): Use the source video resolution if its area is smaller than the specified target video resolution area.

  • 2: Return an error if the source video resolution area is smaller than the specified target video resolution area.

scaletype

string

No

The scaling mode. Valid values:

  • stretch (default): Fixes the width and height or the long and short edges, and forcibly scales and stretches the video to fill the blank space.

  • crop: Scales the video proportionally to the minimum resolution that extends beyond the specified rectangle, and then crops the excess part from the center.

  • fill: Scales the video proportionally to the maximum resolution within the specified rectangle, and then fills the blank space with black from the center.

  • fit: Scales the video proportionally to the maximum resolution within the specified rectangle.

Note

This parameter must be set together with the s parameter.

arotate

int

No

Adaptive resolution orientation. Valid values:

  • 0 (default): disabled.

  • 1: enabled.

vb

int

No

The video stream bitrate. Unit: bit/s.

If you do not specify crf or vb, the default value of crf is 23. If you set vbopt, the vb parameter is required.

vbopt

int

No

The video bitrate option. Valid values:

  • 0: Always use the specified target video bitrate.

  • 1 (default): Use the source video bitrate if it is lower than the specified target video bitrate.

  • 2: Return an error if the source video bitrate is lower than the specified target video bitrate.

crf

float

No

Specifies the constant quality mode. This parameter is mutually exclusive with the vb parameter. Valid values: [0,51]. A larger value indicates lower quality. We recommend that you specify a value in the range of [18,38]. If you do not specify crf or vb, the default value is 23.

maxrate

int

No

The maximum bitrate for dynamic bitrate mode. If you use this parameter, you must also specify the bufsize parameter.

Note

This parameter is valid only when used with the crf parameter.

bufsize

int

No

The decoder buffer size for dynamic bitrate mode. Unit: bit/s.

Note

This parameter is valid only when used with the crf parameter.

an

int

No

Specifies whether to disable the audio stream. Valid values:

  • 0 (default): Do not disable.

  • 1: Disable.

acodec

string

No

The audio encoding method. The value is `aac`.

ar

int

No

The audio sampling rate. Unit: Hertz (Hz). Default: same as the source audio. Valid values:

  • 8000

  • 11025

  • 12000

  • 16000

  • 22050

  • 24000

  • 32000

  • 44100

  • 48000

  • 88200

  • 96000

ac

int

No

The number of sound channels. Default: same as the source audio. Valid values: [1,8].

aq

int

No

The audio quality. This parameter is mutually exclusive with the ab parameter. Valid values: 0 to 100. A larger value indicates higher quality.

ab

int

No

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

abopt

int

No

The audio bitrate option. Valid values:

  • 0: Always use the target audio bitrate.

  • 1 (default): Use the source video bitrate if it is lower than the value of ab.

  • 2: Return an error if the source video bitrate is lower than the value of ab.

Note

The sys/saveas parameter is also used when you generate a live transcoding playlist. For more information, see Save as.

Steps

Live transcoding involves the following two steps:

Note

After you generate a playlist, you can also find playback instructions in the live transcoding topic of the Intelligent Media Management documentation.

1. Generate a live transcoding playlist for a video

Transcoding information

  • Before transcoding

    • Video format: AVI

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

    • Start position: 15 seconds from the beginning of the video

    • Transcoding duration: 1800 seconds

  • Processing method: Generate a playlist

  • After transcoding

    • Segment size: 10 seconds

    • Pre-transcoding duration: 30 seconds

    • Video information

      • Video stream format: H.264

      • Video resolution: 1280 × 720

      • Video frame rate: 25 fps

      • Video bitrate: 2 Mbps

    • Audio information

      • Audio stream format: AAC

      • Audio bitrate: 128 Kbps

    • File storage path prefix: oss://outbucket/outobjprefix/media

Request example

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

Response example

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 the live transcoding stream

Object Storage Service (OSS) provides a dynamic signature mechanism to access audio and video data. When you first access an m3u8 file, add x-oss-process=hls/sign,live_1 to the URL. OSS then automatically signs all TS addresses in the returned playlist using the same signing method that was used for the m3u8 file.

  • hls/sign signing method:

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

# Specify the endpoint of the region where the bucket is located. Replace the value with the actual endpoint.
endpoint = 'yourEndpoint'

# Obtain access credentials from environment variables. Before you run this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
auth = oss2.ProviderAuth(EnvironmentVariableCredentialsProvider())
# The name of the destination bucket.
bucket_name = 'your-oss-bucket-name'
# Set key to the name of the generated playlist, for example, output/media.m3u8.
key = 'output/media.m3u8'

# Specify the bucket instance. All file-related methods must be called through the bucket instance.
# You must use the oss2.AuthV2 signing method.
bucket = oss2.Bucket(auth, 'https://oss-cn-hangzhou.aliyuncs.com', bucket_name)

# The processing method for x-oss-process is hls/sign,live_1.
params = {}
params.update({oss2.Bucket.PROCESS: 'hls/sign,live_1'})

# The signed URL.
# When a signed URL is generated, OSS escapes the forward slashes (/) in the full path of the object by default. This makes the signed URL unusable.
# Set slash_safe to True. OSS does not escape the forward slashes (/) in the full path of the object. The generated signed URL can be used directly.
url = bucket.sign_url('GET', key, 7200, params=params, slash_safe=True)

# The generated URL can be played directly in an HLS player.
print(url)
  • Original m3u8 content

#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
  • Content returned after signing with hls/sign:

#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 an SDK

Generating a live transcoding playlist is a synchronous process. For information about how to use an SDK, see Use an SDK.

FAQ

What output files are included?

An m3u8 file and TS files are generated based on the specified output path prefix. The m3u8 file is generated immediately. If you specify a pre-transcoding duration, TS files for that duration are generated asynchronously. For example, if the pre-transcoding duration is 30 seconds and the segment length is 10 seconds, three TS files are generated. Parts of the video that are not pre-transcoded are transcoded on demand during playback. For example, if a video is never played, no additional TS files are generated. If you start playing a video at the 15-minute mark, transcoding starts from that point. The directory tree of the generated files is as follows:

.
├── 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 the video still play normally after the generated TS files are manually deleted?

Yes, it can. As long as the source video file and the m3u8 playlist are not deleted, the video remains playable. When the m3u8 playlist is requested again, the TS files are regenerated. This method can reduce storage costs without affecting video playback.

Can I use an m3u8 file not generated by live transcoding for live transcoding?

No, you cannot. Only m3u8 files generated by the live transcoding feature can be used for live transcoding.