Skip to main content

Overview

When the built-in microphone and camera capture don’t meet your needs, you can use any MediaStreamTrack as an audio or video source. Common scenarios:
  • Draw content with Canvas and publish it as a video track (avatars, game footage)
  • Synthesize audio with the Web Audio API and publish it
  • Mix several audio tracks and publish the result

Custom audio track

Wrap a MediaStreamTrack with srtc.createLocalCustomAudioTrack(msTrack) to publish it as a local audio track:

Custom video track

Wrap it with srtc.createLocalCustomVideoTrack(msTrack), which suits Canvas drawing scenarios:

Publishing mixed audio (createMixedAudioMediaStreamTrack)

When you need to merge several MediaStreamTracks into one audio track for publishing, use the createMixedAudioMediaStreamTrack utility function:
When to use: when you talk while sharing a video and need to merge microphone audio and system audio into one track for publishing.

Stop a custom track

Custom tracks also support the standard unpublish flow: