Skip to main content
This page covers how cloud recording and stream mixing work as a whole. For the parameters and response structure of each endpoint, see Cloud recording and stream mixing.
To pull the composite video out for playback (HTTP-FLV / RTSP) or push it to a live streaming platform (RTMP / RTMPS), see the Media output guide: start a stream mixing task first, then use the media output endpoints with video=mcu.
This page covers recording the whole channel: the entire channel is mixed into one stream. The output is not necessarily a single file—long recordings are split into segments by duration; see “One recording produces multiple files” below. If what you need is audio split into tracks by speaker and into segments by utterance, that is a different set of endpoints: see Per-speaker voice recording. The differences between the two are in the comparison table below.

One task, three capabilities

task_type is a bit mask. Each of the three independent capabilities takes one bit; add the values of the ones you want at the same time: So 3 = video recording + stream mixing, and 7 = all three.
Don’t treat 3 as a separate “hybrid mode” type. Earlier docs listed the values as “1 recording, 2 mixing, 3 hybrid”, which was wrong—it left out audio recording and misrepresented how the values combine.
The former type 8 (live stream) has been removed; passing 8 or a combination that includes 8 returns parameter error 10070 (invalid request parameters). For live streaming, use 2 (stream mixing) plus the media output endpoints to pull or push; for the migration table, see Media output guide · Migrating from the old endpoints. At upgrade time, the task_type of historical tasks has 8 replaced with 2 (for example, 9 → 3).

One recording produces multiple files

Recording is not “one recording, one file”. Two situations split it into multiple files:
  • The recording is longer than the segment limit (1 hour by default): when transcoding after the task ends, it is split into rolling segments by duration, with continuous time between segments
  • The underlying recording stops automatically partway through because there has been no audio or video for 30 seconds, and is then restarted: a new segment starts, with a time gap between segments
So the data model has two levels: one recording = one task (task_id), and the task has N recording files (record_id): Each file carries these fields, which are enough to build complete playback:
  • seq starts at 1; sorting by it gives the playback order
  • offset_ms is this segment’s offset (in milliseconds) from the start of the whole recording; use it to build the progress bar for continuous playback
  • began_at / ended_at are wall-clock times, for aligning with the timeline of your own business
  • reason=2 means there is a time gap between this segment and the previous one (recording was interrupted and then restarted); continuous playback jumps there
Recording files start transcoding and uploading only after the task ends. There is a wait between stopping the recording and being able to play it, which is longer for long recordings. To tell when a recording is playable, rely on the mcu_record callback (is_last is true on the last one), not on the task status changing to “ended”. See the Callback events guide.

Audio recording is not voice recording

Audio recording (task_type=4) on this page is MCU mixed audio recording: the entire channel is mixed into one audio stream, one file per task. If what you need is audio split into tracks by speaker and into segments by utterance (push-to-talk records, per-person timing, sentence-by-sentence transcription), use Per-speaker voice recording, which is a different set of endpoints: You can run both at the same time; they don’t affect each other.

Choosing a layout

layout_data.layout determines the video layout. There are two kinds:
  • auto (automatic layout): only users with video get a cell; the grid is picked by headcount and switches as people come and go. Works for most cases. div_list has no effect under auto
  • Fixed layouts: the structure does not change with headcount, and you can use div_list to pin specific people to specific cells (see the next section)
If layout is omitted, the server’s default layout is used (auto by default; the deployer can change it). Fixed layouts at a glance (the number in each cell is its index idx; blue marks the large view):
A value not in this table does not return an error; it is silently treated as auto. N in grids_N is not continuous (there is no 7 or 11), so check the table before spelling it out.
The watermark and name labels can fall back to defaults; the layout cannot. When layout_data omits watermark / tag, watermark_type / window_tag_type from the default recording configuration are used. The layout, however, is not taken from that configuration—if you need a fixed layout, pass it in layout_data.layout every time you start a task.

Pinning users to specific cells

layout_data.div_list only works with fixed layouts. Each element pins one cell:
  • cells[0].idx: the cell index, starting at 0, in the same order as <td> cells in an HTML table (left to right, top to bottom); see the table above for the index of the large cell. It must be less than the layout’s cell count
  • uids[0]: the person pinned to this cell (use the uid). If that person is not in the channel, the cell stays empty for them
  • When cells[0].bind_share is true, the cell always shows the current screen share (regardless of who is sharing; uids is ignored). When no one is sharing, the cell stays empty
  • Only the first entry of cells and of uids in an element is used; extras are ignored. To pin several cells, put several elements in div_list
How the remaining cells are filled depends on polling_dur: So if you want a fixed layout with “a few people pinned and everyone else arranged automatically”, you must set polling_dur; otherwise only the pinned cells show video. Typical use: “main speaker pinned to the large view, screen share pinned to one small view, everyone else rotating through the remaining small views”:

Active speaker cell and speaker highlight

Two switches, both set per task (pass them when starting the task or when changing the layout mid-session). They are independent and can be used together:
  • Active speaker cell: mark a cell in div_list with "bind_speaker": true, and that cell automatically shows whoever is currently speaking, switching as the speaker changes. Only works with fixed layouts; at most one such cell per layout; it cannot be the same cell as bind_share; no uids needed for it
  • Speaker highlight: when layout_data.speaker_border is true, the cell of the person currently speaking gets a green border. Works with both automatic and fixed layouts
Switching rhythm of the active speaker cell (fixed, not configurable):
  • A person must keep speaking for about 1.5 seconds before being switched in; coughs and short interjections do not trigger a switch
  • Once switched in, they stay for at least 3 seconds; while the person in the cell is still speaking, no one else can replace them
  • It usually takes 2–3 seconds from someone starting to speak to their video appearing (a person not shown in any other cell needs their video pulled first; until then the cell keeps showing the previous person, so there is no black flash)
  • Before anyone has spoken, the cell shows an “Active speaker” placeholder; after that it keeps the last person who spoke until the next speaker is switched in. If that person leaves the channel, the cell returns to the placeholder
  • If the speaker is also pinned to another cell, both cells show them; without a camera, their avatar and name are shown
Typical use: “4-cell grid, the first 3 cells pinned to 3 guests, the 4th cell automatically showing whoever is speaking, with speaker highlight on”:
Who is speaking is determined by the server from the speech levels reported by each client. Requires server v1.14.0 and compositing service 1.4.0 or later; SIP / H.323 endpoints joining through the device gateway need device gateway 1.8.0 or later to be recognized as speakers. Apps whose media route is a third-party CDN do not support these two features.
In a fixed layout, an invalid combination (more than one active speaker cell, the same cell as bind_share, or a cell index that is negative, out of range, or repeated) returns error code 1043. In an automatic layout div_list is ignored entirely, so bind_speaker is ignored too and no error is returned.

Behavior when no one is in the channel

layout_data.nobody_text determines what happens when no one is in the channel:
  • Empty → recording pauses (recommended, to avoid long stretches of black video)
  • Text set → recording continues and shows the text

Watermark and user name labels

  • watermark.type: 0 default, 1 none, 2 single row, 3 multiple rows. If watermark.text is empty, the task’s title is used as the watermark
  • The position of user name labels is written as a combination of letters: L left, R right, T top, B bottom, which can be combined (LB = bottom left). Empty means no labels

Full sequence

When a channel is destroyed, in-progress tasks stop automatically; you don’t need to call stop first.

Billing note

Video recording, stream mixing, and audio recording (as well as pushes) are server-side capabilities that incur ongoing costs. If you forget to stop a task after starting it, it keeps running until the channel is destroyed—so explicitly call stop in your end-of-call flow rather than relying only on channel destruction.