Skip to main content
This page covers how media output works as a whole: how to choose video and audio, the limits of pulling and pushing, and how to manage push tasks. For the parameters and response structure of each endpoint, see Media output.

One set of sources, two kinds of output

Media output answers two questions: what you want (where the video and the audio each come from) and how you get it (pull or push). The two are independent: Pulling and pushing use the same set of source parameters, so you learn them once.

Choosing video and audio

audio=auto means the audio follows the video: video and audio can’t both be none. Video and audio can come from different users. Common combinations:

The composite video and mixed audio depend on a stream mixing task

When video=mcu, or the audio resolves to the channel’s mixed audio (audio=mix, or auto following the composite video), the channel must have a stream mixing task in progress—task_type includes 2 when you start a recording or stream mixing task. The composite video’s layout, watermark, and user name labels are all configured there; media output only uses the result. See the Cloud recording and stream mixing guide. Without a stream mixing task, pulling and pushing behave differently: Using only a single user’s video and audio (video=user, audio=auto or user) doesn’t depend on a stream mixing task and doesn’t use MCU resources.

Pulling: HTTP-FLV and RTSP

  • The composite video is always H264, so HTTP-FLV with video=mcu isn’t affected by the publishers’ codecs. To pull a single user’s video over HTTP-FLV, have the publisher use H264
  • RTSP defaults to AAC for compatibility: NVRs, surveillance platforms, and most RTSP clients only accept AAC / G.711, not Opus. Use rtsp_audio=opus when you’re sure the player supports Opus
  • The URL is signed and valid for 24 hours by default (adjustable with expire, at most one day); it can be pulled repeatedly by multiple players until it expires. After expiry, new pull requests are rejected, while playback already in progress continues. The actual validity period is the returned expire_at; request a new URL before each playback instead of caching it for a long time
  • On-demand subscription: sources are subscribed only when someone pulls and unsubscribed automatically after the last player disconnects, so nothing is consumed when no one is pulling, and there is no stop endpoint
  • The channel must already be open when you request a pull URL, otherwise 1024 is returned; if the source hasn’t published yet when pulling, the player gets a 404 and should retry; if the user leaves and comes back, the pull doesn’t break, with a gap in between
  • RTSP doesn’t fill in silence: while the audio source is absent (not published, or muted and not sending), the audio is a gap, which players generally handle fine

Limits of audio only (video=none)

Audio-only HTTP-FLV has no video timeline, so it doesn’t fill in silence when the audio source drops out: if the source stops sending for more than 3 seconds, the audio in the FLV has a gap, web players may stall buffering, and it resumes when the source comes back (the connection isn’t closed). If you need continuous audio, use RTSP, or include video.

Push tasks

A push is a separate task: Start a push returns a push_id, which you use to stop the push and check its status.
  • A channel can push multiple streams at once: for example, the composite video to WeChat Channels and a guest’s own video to another platform at the same time
  • Starting again for the same push URL in the same channel doesn’t start another push: if the sources are unchanged, the existing push_id is returned; if they changed, this push is updated to the new sources—so you don’t need to stop and restart to switch the video
  • Push URLs support rtmp:// and rtmps:// and must include the stream key (URLs with an empty stream name such as rtmp://host/app/ return 1075)
  • The channel must already be open; when the channel is destroyed, all of its pushes stop automatically
  • Video is pushed as H264 only, without transcoding (the composite video is always H264; when pushing a single user’s video, have the publisher use H264); audio is transcoded from Opus to AAC
  • Push URLs in the push list are masked (the stream key is replaced with ***); the full URL exists only in your own copy

Push status

When push_id is omitted, the push list returns pushes in progress and those stopped within the last day.

Audio-only pushes

Pushes with video=none work at the protocol level, but many live streaming platforms require video; whether audio only is accepted depends on the platform. When the audio source stops sending, there is no video timeline to fill in silence: a pause within 10 seconds is a gap, and after more than 10 seconds the push disconnects and goes back to waiting. When the source returns, the platform is reconnected, and the platform usually treats it as a new live session.

Push failure alarms

When a push keeps failing (stays in retrying for about 90 seconds), you are notified once through the mcu_alarm callback:
  • task_type 0 means it’s a push alarm, and task_id is then the push_id
  • push_id has the same format as an MCU task ID but isn’t an MCU task—don’t pass it to mcu/detail or other mcu/* endpoints
  • An alarm doesn’t mean the push has stopped; the gateway keeps retrying. Whether it has recovered is shown by status in the push list
waiting never triggers an alarm—an absent source is a normal business state, not a fault.

Error codes

For all error codes, see Error codes.

Self-hosted deployment

Media output is handled by the media gateway, which must be deployed separately with the pull ports open (RTSP 8554, HTTP-FLV 8556) and outbound access to the live streaming platforms allowed (RTMP 1935 / RTMPS 443). See Network and port requirements.

Migrating from the old endpoints

The old single-stream and live streaming endpoints have been removed with no compatibility period. Move your callers to the new endpoints before upgrading:
  • Error code 1047 (invalid MCU push URL) has been removed and replaced by 1075; 1048 (task in push mode has no playback URL) has been removed—pulling and pushing are independent, so this case no longer exists
  • At upgrade time, the task_type of historical tasks (including ended ones) has 8 replaced with 2 (for example, 9 → 3, 12 → 6), so 8 no longer appears in queries or callbacks
  • The mcu_alarm callback for push alarms adds the task_type=0 case; use task_type to tell MCU task alarms from push alarms