Transcode while streaming is a real-time transcoding feature for online video playback that starts playback immediately after upload and transcodes only the segments being watched.
Overview
Unlike ApsaraVideo Media Processing, which requires waiting for full video transcoding to complete after upload before playback can begin, transcode while streaming starts playback immediately after the source video finishes uploading. It only transcodes the video segments needed for playback. This approach delivers:
-
Transcoding during playback—no waiting required.
-
Optimized transcoding with sub-second startup and seek times—near-local playback experience.
-
No transcoding without playback. Even if transcoded files are deleted, they can be regenerated on demand—significantly reduced transcoding and storage costs.
-
Support for dozens of transcoding parameters—highly customizable settings.
-
High compatibility—supports over 300 audio and video formats.
Transcode while streaming does not support anonymous playback.
Workflow
-
Upload your video file to Object Storage Service (OSS).
-
Use the GenerateVideoPlaylist API to quickly generate a media playlist file. Sign the playlist using OSS signing capabilities to obtain a signed playlist URL.
-
The player fetches the signed playlist and begins playback. The transcode while streaming feature triggers automatically during playback.
Scenarios
-
Cloud storage: Users upload videos to cloud drives. Clients instantly select appropriate resolutions based on network conditions for playback. This ensures real-time playback and cross-device compatibility. Since most videos in cloud storage are rarely accessed ("cold"), transcode while streaming avoids transcoding unplayed content, greatly reducing transcoding and storage costs.
-
Chat app video previews: In instant messaging or social platforms, once the sender finishes uploading (and the server receives the file), the recipient can start playback immediately—enhancing real-time communication. Transcoded files for long-unviewed historical messages can be periodically cleaned up to lower storage costs, and playback remains instant upon re-access.
-
Online forums and blogs: After users upload source videos for sharing, others can immediately play transcoded versions—ensuring smooth playback, high definition, and broad format compatibility.
Features
The following table describes additional features.
|
Feature |
Description |
|
Standardization |
|
|
Low cost |
|
|
High efficiency |
|
Supported audio and video formats
Transcode while streaming supports over 300 audio and video formats. The following table lists some commonly supported formats.
|
Input video formats |
avi, mov, flv, mkv, webm, mpeg, wmv, rm, vob, ts, and all other mainstream formats |
|
Input audio formats |
mp3, wav, aac, flac, wma, and all other mainstream formats |
|
Output container format |
ts |
Prerequisites
-
Activate OSS, create a bucket, and upload files to it. For details, see Quick Start in console.
-
Activate Intelligent Media Management (IMM) and create a project. For details, see Activate service and Create project.
NoteYou can also call the CreateProject API to create a project.
You can call the ListProjects API to list all projects in a specified region.
-
Grant your Resource Access Management (RAM) user the required permissions for IMM operations.
-
Before using transcode while streaming, bind an IMM project. For instructions on binding via console or API, see Quick Start and Bind OSS bucket.
-
If hotlink protection is enabled on the bucket containing your source or output videos, ensure your hotlink protection policy allows empty Referer.
-
If your player needs cross-domain access to OSS, enable OSS cross-origin resource sharing (CORS) for the target bucket. See CORS settings.
Usage
Media Playlist example
Transcoding configuration
-
Source video information
-
Format: AVI
-
Source URI: oss://your-oss-bucket-name/test.avi
-
-
Target video
-
Segment duration: 10 seconds
-
Pre-transcode duration: 36 seconds
-
Video codec: H.264
-
Resolution: 1280×720
-
Frame rate: 25 fps
-
Video bitrate: 2 Mbps
-
Audio codec: AAC
-
Audio bitrate: 128 Kbps
-
Output path prefix: oss://your-oss-bucket-name/output/media
-
Step 1: Generate playlist
Step 2: Sign the playlist
Step 3: Play the video
Master Playlist example
Transcoding configuration
-
Source video
-
Format: AVI
-
Source URI: oss://your-oss-bucket-name/test.avi
-
-
Master playlist URI: oss://your-oss-bucket-name/output/master.m3u8
-
Target video 1
-
Segment duration: 10 seconds
-
Pre-transcode duration: 36 seconds
-
Video codec: H.264
-
Resolution: 1920×1080
-
Frame rate: 25 fps
-
Audio codec: AAC
-
Audio bitrate: 128 Kbps
-
Output path prefix: oss://your-oss-bucket-name/output/1080p/1080p
-
-
Target video 2
-
Segment duration: 10 seconds
-
Pre-transcode duration: 36 seconds
-
Video codec: H.264
-
Resolution: 1280×720
-
Frame rate: 25 fps
-
Audio codec: AAC
-
Audio bitrate: 96 Kbps
-
Output path prefix: oss://your-oss-bucket-name/output/720p/720p
-
-
Target video 3
-
Segment duration: 10 seconds
-
Pre-transcode duration: 36 seconds
-
Video codec: H.264
-
Resolution: 720×540
-
Frame rate: 25 fps
-
Audio codec: AAC
-
Audio bitrate: 64 Kbps
-
Output path prefix: oss://your-oss-bucket-name/output/540p/540p
-
Step 1: Generate playlist
Step 2: Sign the playlist
Step 3: Play the video
FAQ
Do I need a custom player?
No. Transcode while streaming supports standard HLS protocol. Use any standard HLS-compatible player (such as the Alibaba Cloud Aliplayer or Safari browser).
What output files are generated?
We generate an m3u8 file and TS files based on the input path prefix you specify. The m3u8 file is generated immediately.
If you specify a pre-transcode duration, the system asynchronously generates corresponding TS files. Unspecified segments are transcoded on demand during playback. If a video is never played, no TS files are generated for those segments. For example, if playback starts at the 15-minute mark, transcoding begins from that point. The resulting directory structure looks like this:
.
├── outobjprefix.m3u8
├── outobjprefix-c280f054328fcde47c1732a8f2915009-0.ts
├── outobjprefix-c280f054328fcde47c1732a8f2915009-1.ts
├── outobjprefix-c280f054328fcde47c1732a8f2915009-2.ts
├── outobjprefix-c280f054328fcde47c1732a8f2915009-3.ts
Can I still play the video if I manually delete generated ts files?
Yes. As long as the source video and m3u8 playlist remain, deleting some or all ts files does not affect playback. When the m3u8 playlist is requested again, missing ts files are regenerated. This lets you clean up ts files for rarely viewed videos to reduce storage costs without impacting future playback.
Can I use a non-transcode-while-streaming m3u8 file for this feature?
No. You cannot use m3u8 files generated outside the transcode while streaming process to enable this feature.
Can I use CDN to accelerate transcode while streaming?
Yes. For details, see Use CDN to accelerate transcode while streaming.