Creates a just-in-time transcoding playlist that generates an M3U8 file from a video file. The playlist can be played immediately after generation, and transcoding is performed on demand based on playback progress. Compared with offline transcoding, this significantly reduces transcoding wait time and substantially lowers transcoding and storage costs.
Operation description
Before you use this operation, make sure that you understand the billing of Intelligent Media Management (IMM) and its pricing.
Before you invoke this operation, make sure that an active project exists in the current region. For more information, see Project management.
- By default, this operation processes only one video, audio, or subtitle stream. You can configure the number of video, audio, and subtitle streams to process.
Important The Video, Audio, and Subtitle parameters under Targets cannot all be empty. An empty value indicates that the corresponding processing is disabled. For example, if Video is empty, video processing is disabled and the output TS files do not contain video streams.
The minimum duration of the source video is approximately 0.x seconds, which varies depending on the output frame rate.
This operation supports generating both Media Playlists and Master Playlists. Pay attention to the metric descriptions in this document.
This is a synchronous operation. Synchronous or asynchronous transcoding is triggered only during playback or pre-transcoding. You can set the Notification parameter to receive transcoding task results through message notifications.
For more information about this feature, see Just-in-time transcoding.
OSS data processing also provides a playlist generation feature, but it only supports generating Media Playlists with simplified parameters. For details, see Generate a playlist in OSS data processing.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
imm:GenerateVideoPlaylist |
none |
*Project
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ProjectName |
string |
Yes |
The project name. For information about how to obtain the project name, see Create a project. |
immtest |
| UserData |
string |
No |
The custom information, which is returned in asynchronous message notifications. This helps you associate message notifications within your system. Maximum length: 2,048 bytes. |
{"ID": "user1","Name": "test-user1","Avatar": "http://example.com?id=user1"} |
| SourceURI |
string |
Yes |
The OSS URI of the video. The OSS URI follows the format oss://${Bucket}/${Object}, where ${Bucket} is the name of the OSS bucket in the same region as the current project, and ${Object} is the full path of the file including the file name extension. Note
Only OSS buckets with Standard storage are supported. Buckets with hotlink protection whitelists configured are not supported. |
oss://test-bucket/test-source-object/video.mp4 |
| SourceStartTime |
number |
No |
The start time for generating the playlist. Unit: seconds. Valid values:
Note
You can set this parameter together with SourceDuration to generate a playlist for a specific portion of the source video. |
0 |
| SourceDuration |
number |
No |
The duration for generating the playlist. Unit: seconds. Valid values:
Note
If the time point corresponding to the specified parameter exceeds the end of the source video, the default value is used. |
0 |
| SourceSubtitles |
array<object> |
No |
The list of subtitles to add. Default value: empty. A maximum of two subtitles are supported. |
|
|
object |
No |
The subtitle information. |
||
| URI |
string |
Yes |
The OSS URI of the subtitle to embed. The OSS URI follows the format oss://${Bucket}/${Object}, where ${Bucket} is the name of the OSS bucket in the same region as the current project, and ${Object} is the full path of the file. Note
The MasterURI parameter must not be empty, and the OSS URI |
oss://test-bucket/test-object/subtitle/eng.vtt |
| Language |
string |
No |
The subtitle language. The value follows the ISO 639-2 standard. Default value: empty. |
eng |
| MasterURI |
string |
No |
The OSS URI of the Master Playlist. The OSS URI follows the format oss://${Bucket}/${Object}, where ${Bucket} is the name of the OSS bucket in the same region as the current project, and ${Object} is the full path of the file with the ".m3u8" extension. Note
If the playlist has subtitle input or multiple Target outputs, MasterURI is required. The subtitle URI or Target URI must be in the same directory as or a subdirectory of MasterURI. |
oss://test-bucket/test-object/master.m3u8 |
| Targets |
array<object> |
Yes |
The array of just-in-time transcoding playlists. The maximum array length is 6. Each Target corresponds to at most one video Media Playlist and one or more subtitle Media Playlists. Note
If more than one Target is configured, the MasterURI parameter must not be empty. |
|
|
array<object> |
No |
The details of the just-in-time transcoding task. |
||
| URI |
string |
No |
The OSS URI prefix for the just-in-time transcoding output files, including M3U8 files and TS files. The OSS URI follows the format oss://${Bucket}/${Object}, where ${Bucket} is the name of the OSS bucket in the same region as the current project, and ${Object} is the full path prefix of the file without the file name extension.
Note
If the MasterURI parameter is not empty, the URI must be in the same directory as or a subdirectory of the MasterURI parameter. |
oss://test-bucket/test-object/output-video |
| Video | TargetVideo |
No |
The video processing parameter settings. An empty value (default) indicates that video processing is disabled and the output TS files do not contain video streams. Note
The Video and Subtitle fields within the same Target are mutually exclusive. If the Video field is set, the Subtitle field is ignored. |
|
| Audio | TargetAudio |
No |
The audio processing parameter settings. An empty value (default) indicates that audio processing is disabled and the output TS files do not contain audio streams. Note
The Audio and Subtitle fields within the same Target are mutually exclusive. If the Audio field is set, the Subtitle field is ignored. Audio and Video can be set at the same time. Audio specifies the audio information in the output video. You can also set only Audio to generate audio-only output. |
|
| Subtitle | TargetSubtitle |
No |
The subtitle processing parameter settings. Note
The Subtitle field is mutually exclusive with the Video and Audio fields within the same Target. Subtitles are generated only when Subtitle is set independently. |
|
| TranscodeAhead |
integer |
No |
The number of TS files to transcode ahead when just-in-time transcoding is triggered. By default, 2 minutes of video is transcoded ahead.
|
12 |
| Duration |
number |
No |
The playback duration of a single TS file. Unit: seconds. Default value: 10. Valid values: [5, 15]. |
10 |
| InitialTranscode |
number |
No |
The initial transcoding duration. Unit: seconds. Default value: 30.
Note
This parameter is mainly used to reduce the wait time for the first playback and improve the playback experience. If you want to replace a traditional VOD scenario, try initially transcoding the entire video. |
30 |
| InitialSegments |
array |
No |
The array of initial transcoding TS file durations. The maximum array length is 6. Default value: empty. This parameter is independent of the Duration parameter. |
|
|
number |
No |
The duration of an initial transcoding TS file. Valid values: [1, Duration].
Note
Customizing smaller initial transcoding TS file durations makes video loading smoother. |
2 |
|
| Tags |
object |
No |
The OSS object tags to add to the generated TS files. You can use OSS tags to control the lifecycle of OSS files. Note
The tag values at this level are merged with the Tags defined at the parent level to form the tag values for the current Target. If a tag with the same name exists, the value at this level takes precedence. |
|
|
string |
No |
The tag value. |
{\"key1\":\"value1\"} |
|
| Tags |
object |
No |
The OSS object tags to add to the generated TS files. You can use tags to control the lifecycle of OSS files. |
{"key1": "value1", "key2": "value2"} |
|
string |
No |
The tag value. |
{"key1": "value1", "key2": "value2"} |
|
| CredentialConfig | CredentialConfig |
No |
Leave this parameter empty unless you have special requirements. The China authorization configuration. This parameter is optional. For more information, see Use chained authorization to access resources of other entities. |
|
| Notification | Notification |
No |
The message notification configuration. Click Notification for details. For the format of asynchronous notification messages, see Asynchronous notification message format. |
|
| OverwritePolicy |
string |
No |
The overwrite policy when a Media Playlist already exists. Valid values:
|
overwrite |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| RequestId |
string |
The request ID. |
CA995EFD-083D-4F40-BE8A-BDF75FFF***** |
| Duration |
number |
The total duration of the output video. |
1082 |
| Token |
string |
The token of the Master Playlist. |
92376fbb-171f-4259-913f-705f7ee0**** |
| MasterURI |
string |
The OSS URI of the Master Playlist. |
oss://test-bucket/test-object/master.m3u8 |
| VideoPlaylist |
array<object> |
The list of video Media Playlist files. |
|
|
object |
The video Media Playlist file information. |
||
| Token |
string |
The token generated for the video Media Playlist. You can use this parameter to construct the addresses of the generated TS files. Note
Based on the returned Token value, you can construct the addresses of the transcoded TS files. The format is: oss://${Bucket}/${Object}-${Token}-${Index}.ts, where oss://${Bucket}/${Object} is the Target URI specified in the input parameters, ${Token} is the returned parameter, and ${Index} is the sequence number of the TS file. |
affe0c6042f09722fec95a21b8b****** |
| URI |
string |
The OSS URI of the video Media Playlist. |
oss://test-bucket/test-object/output-video.m3u8 |
| Resolution |
string |
The video resolution. |
640x480 |
| FrameRate |
string |
The video frame rate. |
25/1 |
| AudioPlaylist |
array<object> |
The list of audio Media Playlist files. |
|
|
object |
The audio Media Playlist file information. |
||
| Token |
string |
The token generated for the audio Media Playlist. You can use this parameter to construct the addresses of the generated TS files. |
affe0c6042f09722fec95a21b8b****** |
| URI |
string |
The OSS URI of the audio Media Playlist. |
oss://test-bucket/test-object/output-audio.m3u8 |
| Channels |
integer |
The number of audio channels. |
1 |
| SubtitlePlaylist |
array<object> |
The list of subtitle Media Playlist files. |
|
|
object |
The subtitle Media Playlist file information. |
||
| Token |
string |
The token generated for the subtitle Media Playlist. You can use this parameter to construct the addresses of the generated subtitle files. Note
Based on the returned Token value, you can construct the addresses of the transcoded subtitle files. The format is: oss://${Bucket}/${Object}-${Token}_${Index}.ts, where oss://${Bucket}/${Object} is the Subtitle URI specified in the input parameters, ${Token} is the returned parameter, and ${Index} is the sequence number of the subtitle file. |
affe0c6042f09722fec95a21b8b****** |
| URI |
string |
The OSS URI of the subtitle Media Playlist. |
oss://test-bucket/test-object/output-subtitle.m3u8 |
| Language |
string |
The language of the subtitle stream. Note
The language is obtained from the subtitle stream information of the source video specified by SourceURI. If the source video does not contain language information, an empty value is returned. |
eng |
| Index |
integer |
The sequence number of the subtitle stream, starting from 0. |
1 |
Examples
Success response
JSON format
{
"RequestId": "CA995EFD-083D-4F40-BE8A-BDF75FFF*****",
"Duration": 1082,
"Token": "92376fbb-171f-4259-913f-705f7ee0****",
"MasterURI": "oss://test-bucket/test-object/master.m3u8",
"VideoPlaylist": [
{
"Token": "affe0c6042f09722fec95a21b8b******",
"URI": "oss://test-bucket/test-object/output-video.m3u8",
"Resolution": "640x480",
"FrameRate": "25/1"
}
],
"AudioPlaylist": [
{
"Token": "affe0c6042f09722fec95a21b8b******",
"URI": "oss://test-bucket/test-object/output-audio.m3u8",
"Channels": 1
}
],
"SubtitlePlaylist": [
{
"Token": "affe0c6042f09722fec95a21b8b******",
"URI": "oss://test-bucket/test-object/output-subtitle.m3u8",
"Language": "eng",
"Index": 1
}
]
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.