Membuat tugas penggabungan aliran dan transkoding.
Deskripsi operasi
By default, each application ID supports a maximum of 200 single-stream ingest tasks and 40 stream mixing and transcoding tasks. To increase the quota, submit a ticket.
Stream mixing task lifecycle
Start
-
When a streamer starts streaming for the first time, you can call StartLiveMPUTask to start a bypass task.
-
If no users are in the channel, a "channel does not exist" error is returned.
-
The bypass stream is output only when a user starts stream ingest. If the user in a single-stream task does not ingest a stream, the bypass stream cannot be played.
-
For a stream mixing task, at least one user must be ingesting a stream for the bypass stream to be playable. The layout area for users who are not ingesting streams shows a black screen.
-
-
You can record the bypass task status, task type, and task parameters on your business server.
-
Task status: Started, Stopped.
-
Task type: Single-stream, Stream mixing.
-
Task parameters: The latest input parameters. For example, after a successful call to UpdateLiveMPUTask, record the latest task parameters.
-
-
In co-streaming or PK scenarios, if a task has been updated to a stream mixing task and the streamer unexpectedly leaves and then rejoins the channel, your business server can call StartLiveMPUTask to restart the stream mixing task based on the saved task type and parameters.
-
If the system has not automatically cleared the task before you start it, the task starts successfully.
-
If the system has not yet cleared the task, a Task already exists error code is returned.
-
End
-
When a streamer leaves the channel, call StopLiveMPUTask to stop the bypass task.
-
If all users in the task leave the channel and StopLiveMPUTask is not called, the system automatically stops the bypass task after 2 minutes.
QPS limits
The queries per second (QPS) limit for a single user for this API is 500 calls/second. If you exceed this limit, API calls are throttled. This may affect your business. We recommend that you call this API reasonably.
Coba sekarang
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
live:StartLiveMPUTask |
create |
*全部资源
|
None | None |
Parameter permintaan
|
Parameter |
Type |
Required |
Description |
Example |
| AppId |
string |
Yes |
ID aplikasi. Hanya satu ID yang didukung. Dapat berisi huruf besar, huruf kecil, digit, garis bawah (_), dan tanda hubung (-). Panjang maksimum adalah 64 karakter. |
yourAppId |
| ChannelId |
string |
Yes |
ID saluran. Hanya satu ID yang didukung. Dapat berisi huruf besar, huruf kecil, digit, garis bawah (_), dan tanda hubung (-). Panjang maksimum adalah 64 karakter. |
yourChannelId |
| TaskId |
string |
Yes |
ID tugas. Hanya satu ID yang didukung. Dapat berisi huruf besar, huruf kecil, digit, garis bawah (_), dan tanda hubung (-). Panjang maksimum adalah 55 karakter. ID ini merupakan pengidentifikasi unik untuk tugas pengambilan aliran bypass. Jika tugas dengan ID yang sama masih ada dan belum dihapus saat Anda memulai tugas baru, `InvalidParam` akan dikembalikan. |
yourTaskId |
| MixMode |
string |
Yes |
Mode penggabungan aliran. Nilai valid:
|
0 |
| StreamURL |
string |
No |
URL ingest live. Hanya protokol RTMP yang didukung. Hanya satu URL yang didukung. Panjang maksimum adalah 2048 karakter. Untuk informasi tentang cara membuat URL, lihat URL ingest dan URL pemutaran. Catatan
|
rtmp://example.com/live/stream |
| MultiStreamURL |
array<object> |
No |
Parameter untuk ingest ke beberapa URL. Anda dapat menentukan beberapa URL ingest live. Catatan
Saat Anda menyetel URL ingest untuk suatu tugas, Anda harus mengonfigurasi parameter StreamURL atau parameter MultiStreamURL, tetapi tidak keduanya. |
|
|
object |
No |
|||
| URL |
string |
No |
The live ingest URL. Only the RTMP protocol is supported. The maximum length is 2048 characters. For information about how to generate the URL, see Ingest URLs and playback URLs. |
rtmp://example.com/live/stream**** |
| IsAliCdn |
boolean |
No |
Specifies whether to ingest the stream to Alibaba Cloud CDN.
Catatan
The default value is false. |
false |
| Region |
string |
No |
Wilayah tempat layanan penggabungan aliran berada. Nilai valid:
|
CN-Shanghai |
| MaxIdleTime |
string |
No |
Periode batas pengatur waktu idle. Unit: detik. Nilai harus berada dalam rentang [10, 86400]. Catatan
Jika Anda menyetel parameter ini, tugas akan otomatis dihentikan ketika idle melebihi MaxIdleTime. Jika Anda tidak menyetel parameter ini, tugas akan dihentikan segera setelah saluran ditutup. |
10 |
| SingleSubParams |
object |
No |
Parameter untuk pengambilan aliran tunggal. Parameter ini wajib diisi ketika MixMode disetel ke 0. Jangan setel parameter ini untuk penggabungan aliran dan transkoding. |
|
| SourceType |
string |
No |
The type of video input stream in single-stream ingest mode. This parameter is valid only for video streams (StreamType=2). Valid values:
|
camera |
| StreamType |
string |
No |
The type of stream to ingest in single-stream ingest mode. Valid values:
|
0 |
| UserId |
string |
Yes |
The ID of the user whose stream is ingested. Only one stream can be ingested at a time. |
yourSubUserId |
| TranscodeParams |
object |
No |
Parameter untuk penggabungan aliran dan transkoding. Parameter ini wajib diisi ketika MixMode disetel ke 1. Jangan setel parameter ini untuk pengambilan aliran tunggal. |
|
| Background |
object |
No |
The global background image for the mixed stream. |
|
| RenderMode |
string |
No |
The display mode of the output video. Valid values:
|
1 |
| URL |
string |
No |
The URL of the global background image. The maximum length is 2048 characters. |
yourImageUrl |
| EncodeParams |
object |
No |
The encoding parameters for the output stream. |
|
| AudioOnly |
string |
No |
Specifies whether the stream is audio-only. Valid values:
|
false |
| AudioBitrate |
string |
No |
The audio bitrate. Unit: kbps. The value must be in the range of [8, 500]. |
128 |
| AudioChannels |
string |
No |
The number of audio channels. Valid values: 1, 2. |
2 |
| AudioSampleRate |
string |
No |
The audio sampling rate. Unit: Hz. Valid values: 8000, 16000, 32000, 44100, 48000. |
44100 |
| VideoCodec |
string |
No |
The video encoding format. Valid values:
|
H.264 |
| VideoBitrate |
string |
No |
The video bitrate. Unit: kbps. The value must be in the range of [1, 10000]. |
3500 |
| VideoFramerate |
string |
No |
The video frame rate. Unit: fps. The value must be in the range of [1, 60]. |
25 |
| VideoGop |
string |
No |
The video GOP size. The value must be in the range of [1, 60]. |
20 |
| VideoHeight |
string |
No |
The video height. Unit: pixels. The value must be in the range of [0, 1920]. |
1000 |
| VideoWidth |
string |
No |
The video width. Unit: pixels. The value must be in the range of [0, 1920]. |
1920 |
| EnhancedParam |
string |
No |
The enhanced encoding parameters. This is a JSON string. The supported optional configurations include `profile` and `preset`.
Catatan
For example, "superfast" is mainly used for real-time communication. If you are not an expert in encoders, do not set this option. |
{"profile": "high", "preset": "veryfast"} |
| Layout |
object |
No |
The video layout information. Catatan
For video transcoding, you must specify the video layout information, including coordinates (X, Y), pane dimensions (Width, Height), and stacking order (ZOrder). For audio-only transcoding, do not specify video layout information. |
|
| UserPanes |
array<object> |
No |
The information about user panes in the mixed stream. |
|
|
array<object> |
No |
The information about user panes in the mixed stream. |
||
| UserInfo |
object |
No |
The information about the user whose stream is played in the pane. If you leave this parameter empty, the system automatically sets this parameter based on the order in which streamers join the channel. Catatan
|
|
| SourceType |
string |
No |
The type of the video source. This parameter is valid only when you set StreamType to 2. Valid values:
|
camera |
| ChannelId |
string |
No |
The ID of the channel where the user is. If the user is in the same channel, you can leave this parameter empty. We recommend that you specify this parameter when you perform stream mixing across channels. |
yourChannelId |
| UserId |
string |
No |
The user ID. |
yourSubUserId |
| Height |
string |
No |
The height of the pane. The value is normalized. |
0.2632 |
| Width |
string |
No |
The width of the pane. The value is normalized. |
0.3564 |
| X |
string |
No |
The x-coordinate of the pane. The value is normalized. |
0.2456 |
| Y |
string |
No |
The y-coordinate of the pane. The value is normalized. |
0.3789 |
| ZOrder |
string |
No |
The layer in which the pane resides. A value of 0 indicates the bottom layer. Each increment of the value by 1 indicates the next upper layer. |
0 |
| BackgroundImageUrl |
string |
No |
The URL of the background image of the pane. The URL can be up to 2,048 characters in length. This image is displayed if the user turns off the camera or is not present in the channel. |
yourImageUrl |
| RenderMode |
string |
No |
The display mode of the pane. Valid values:
|
1 |
| UserInfos |
array<object> |
No |
The information about the users to subscribe to for stream mixing. If you do not specify users, all users are included in the mixed stream. |
|
|
object |
No |
The user information for stream mixing. |
||
| SourceType |
string |
No |
The type of video input stream to subscribe to for stream mixing. This parameter is valid only for video streams (StreamType=2). Valid values:
|
camera |
| StreamType |
string |
No |
The type of stream to subscribe to for stream mixing. Valid values:
|
0 |
| ChannelId |
string |
No |
The ID of the channel where the subscribed user is located. You do not need to set this parameter for users in the same channel. For cross-channel stream mixing, set this parameter. |
yourChannelId |
| UserId |
string |
Yes |
The ID of the user to subscribe to for stream mixing. |
yourSubUserId |
| SeiParams |
object |
No |
Parameter konfigurasi SEI. |
|
| LayoutVolume |
object |
No |
The layout and volume SEI. The content of this parameter can be empty, which means the default layout and volume SEI is carried. |
|
| FollowIdr |
string |
No |
Specifies whether to ensure that SEI is carried when sending an IDR keyframe. Valid values:
|
0 |
| Interval |
string |
No |
The SEI sending interval. Unit: milliseconds. The value must be in the range of [1000, 5000]. |
1000 |
| PassThrough |
object |
No |
The pass-through SEI. |
|
| FollowIdr |
string |
No |
Specifies whether to ensure that SEI is carried when sending an IDR keyframe. Valid values:
|
0 |
| Interval |
string |
No |
The SEI sending interval. Unit: milliseconds. The value must be in the range of [1000, 5000]. |
1000 |
| PayloadContent |
string |
No |
The payload content of the pass-through SEI. |
yourPayloadContent |
| PayloadContentKey |
string |
No |
The key corresponding to the payload content of the pass-through SEI. If not set, the default key is `udd`. |
yourPayloadContentKey |
| PayloadType |
string |
No |
The custom payload_type of the SEI message. The value must be in the range of 100-254. If not set, the default payload_type is 5. |
100 |
SEI tata letak dan volume
| Parameter | Deskripsi |
| canvas | Informasi kanvas. Parameter: - w: Lebar kanvas dalam piksel. - h: Tinggi kanvas dalam piksel. - bgnd: Warna latar belakang kanvas, sebagai bilangan bulat heksadesimal dalam format RGB. |
| stream | Informasi aliran video. Parameter: - uid: ID pengguna Streamer. - paneid: ID panel Wilayah, dalam rentang [0, 8]. - zorder: Pesanan penumpukan Wilayah, dalam rentang [0, 99]. - x: Koordinat X Wilayah pada kanvas, sebagai persentase yang dinormalisasi. - y: Koordinat Y Wilayah pada kanvas, sebagai persentase yang dinormalisasi. - w: Lebar Wilayah, sebagai persentase yang dinormalisasi. - h: Tinggi Wilayah, sebagai persentase yang dinormalisasi. - type: Tipe aliran video di Wilayah. 0: Kamera. 1: Berbagi layar. - status: Status aliran video di Wilayah. 0: Belum diambil. 1: Sudah diambil. - muted: Status bisu Streamer. 0: Tidak dibisukan. 1: Dibisukan. Dalam skenario PK, jika Streamer A membisukan Streamer B, kolom muted untuk Streamer B menampilkan status dibisukan.- vol: Volume Streamer dalam desibel, dalam rentang [0, 255]. - vad: Deteksi aktivitas suara. Nilai berada dalam rentang [0, 150]. 150 menunjukkan bahwa suara terdeteksi. Nilai selain 150 menunjukkan laju peluruhan dari suara ke keheningan. |
| ts | Stempel pengatur waktu sistem operasi saat informasi ini dihasilkan, dalam milidetik. |
| ver | Versi format SEI, seperti 1.0.0.20220915. |
| udd | Peristiwa berbasis skenario kustom yang dikirim melalui parameter PassThrough. Konten ditentukan oleh parameter PayloadContent. |
Ketika pengguna mengambil aliran yang di-ingest, data media streaming berisi informasi SEI. Anda dapat menggunakan fitur ini untuk meneruskan informasi kustom. Informasi SEI dapat diambil dari data frame video selama dekoding aliran video. Untuk format spesifik, lihat parameter `PassThrough`.
Contoh untuk skenario co-streaming:
Jika hanya ada satu Streamer, koleksi `stream` dalam informasi SEI yang diterima penonton hanya berisi informasi untuk satu anggota. Jika Streamer berada dalam sesi co-streaming atau PK, koleksi `stream` berisi informasi untuk beberapa anggota.
Misalnya, ketika Streamer `streamer111` melakukan streaming sendiri, format frame SEI yang diterima penonton adalah sebagai berikut:{"canvas":{"w":1920,"h":1080,"bgnd":0},"stream":[{"uid":"streamer111","paneid":-1,"zorder":0,"x":0,"y":0,"w":0,"h":0,"type":0,"status":1,"muted":0,"vol":0,"vad":0}],"ver":"1.0.0.20220915","ts":1697696105170}
Ketika Streamer `streamer111` melakukan co-streaming dengan penonton `viewer222`, format frame SEI yang diterima penonton adalah sebagai berikut:{"canvas":{"w":1920,"h":1080,"bgnd":0},"stream":[{"uid":"streamer111","paneid":0,"zorder":1,"x":0,"y":0.25,"w":0.5,"h":0.5,"type":0,"status":1,"muted":0,"vol":1,"vad":119},{"uid":"viewer222","paneid":1,"zorder":1,"x":0.5018382,"y":0.25,"w":0.5,"h":0.5,"type":0,"status":1,"muted":0,"vol":60,"vad":123}],"ver":"1.0.0.20220915","ts":1697696106230}
Dengan memeriksa jumlah elemen dalam array `stream`, Anda dapat menentukan apakah tata letak live telah berubah. Jika array `stream` memiliki satu elemen, satu Streamer sedang melakukan ingest aliran. Jika array `stream` memiliki lebih dari satu elemen, Streamer berada dalam sesi co-streaming atau PK. Informasi tata letak untuk setiap anggota menunjukkan posisi spesifiknya dalam tata letak aliran yang digabungkan.
.
SEI pass-through
-
Untuk menggunakan SEI kustom, Anda dapat memanggil perintah StartLiveMPUTask untuk memulai tugas penggabungan aliran dan ingest serta menentukan `PayloadContent` di parameter `PassThrough`. Anda juga dapat memanggil perintah UpdateLiveMPUTask untuk memperbarui tugas dan menentukan `PayloadContent` di parameter `PassThrough`.
-
SEI kustom dapat dikirim secara periodik. Anda dapat menyetel periode menggunakan parameter `Interval` di `PassThrough`. Unitnya adalah milidetik.
-
SEI kustom juga dapat dikirim bersama keyframe. Anda dapat menyetelnya menggunakan parameter `FollowIdr` di `PassThrough`.
-
Anda dapat mengirim SEI secara periodik dan juga bersama keyframe. Misalnya, `Interval:1000` dan `FollowIdr: 1` berarti SEI kustom dikirim setiap 1000 md dan juga bersama setiap keyframe.
-
Jika Anda tidak menyetel `Interval` atau `FollowIdr`, SEI kustom hanya dikirim sekali saat API dipanggil.
-
Misalnya, ketika Streamer `streamer111` melakukan streaming sendiri, Anda dapat memanggil perintah UpdateLiveMPUTask untuk mengirim SEI periodik. Di parameter `PassThrough`, setel `Interval` ke 1000, `FollowIdr` ke 0, lalu `PayloadContent` ke "hello world". Paket SEI kustom kemudian dikirim setiap 1000 md secara berurutan. Format frame SEI yang diterima penonton adalah sebagai berikut:{"canvas":{"w":1920,"h":1080,"bgnd":0},"stream":[{"uid":"streamer111","paneid":-1,"zorder":0,"x":0,"y":0,"w":0,"h":0,"type":0,"status":1,"muted":0,"vol":0,"vad":0}],"ver":"1.0.0.20220915","ts":1697696109876,"udd":"hello world"}
.
Penggabungan aliran multi-pengguna lintas saluran
Untuk menggabungkan aliran dari beberapa Streamer di beberapa saluran dan meng-ingest aliran yang digabungkan ke layanan live streaming, Anda harus menyediakan UserID dan ChannelID Streamer yang memulai panggilan lintas saluran, bersama dengan UserID peserta lainnya, sebagai parameter input ketika Anda membuat tugas penggabungan aliran. Lihat contoh berikut dengan format sebagai berikut: Dalam skenario PK live, Streamer `userA` di saluran `channelA` memulai PK lintas saluran dengan Streamer `userB` di saluran `channelB` menggunakan API klien. Aliran gabungan dari kedua Streamer dikeluarkan ke penonton di saluran `channelA`. Dalam hal ini, parameter saluran dan pengguna untuk membuat tugas penggabungan aliran ditentukan sebagai berikut:
-
ChannelID: Tentukan `channelA`.
-
UserInfos->UserId: Tentukan `userA` dan `userB` secara berurutan.
Sebelum membuat tugas penggabungan aliran multi-pengguna lintas saluran, panggilan lintas saluran harus dimulai melalui SDK klien. Jika pengguna di saluran yang berbeda tidak berada dalam panggilan, Anda tidak dapat membuat tugas penggabungan aliran lintas saluran. Untuk informasi lebih lanjut tentang cara memulai panggilan lintas saluran, lihat Berlangganan lintas saluran.
Elemen respons
|
Element |
Type |
Description |
Example |
|
object |
The request ID. |
||
| RequestId |
string |
The request ID. |
0F72851F-5DC1-1979-9B2C-450040316C3E |
Contoh
Respons sukses
JSONformat
{
"RequestId": "0F72851F-5DC1-1979-9B2C-450040316C3E"
}
Kode kesalahan
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParam | %s. | |
| 400 | InvalidAppId | %s, please check and try again later. | |
| 400 | MissingParam | %s, please check and try again later. | |
| 500 | InternalError | InternalError | |
| 403 | OperationDenied | Your account has not enabled the Live service | |
| 403 | Forbidden | %s, please check and try again later. |
Lihat Error Codes untuk daftar lengkap.
Catatan rilis
Lihat Release Notes untuk daftar lengkap.