Skip to main content

Overview

Local recording suits recording “the call view the current user sees” in the browser: for example a 3-tile or 9-tile grid, the current page after paging, or a layout that prioritizes screen sharing. The SDK draws the video tracks you pass in onto an internal canvas, mixes the audio tracks into the same recording stream, and finally outputs a webm file through MediaRecorder. Your app decides which videos to record right now and where each one goes on the recording canvas. LocalCompositeRecorder only handles media compositing and the recording lifecycle and has no built-in call layout algorithm—your app passes in the layout based on the current UI view.

Basic usage

Once you have the blob, you can download or upload it:

Start options

LocalCompositeRecorderStartOptions for start(options): LocalCompositeRecorderVideoItem (a single video item):

Input tracks

Both videoItems[].track and audioTracks[] accept an SDK Track or a native browser MediaStreamTrack:
  • LocalVideoTrack
  • RemoteVideoTrack
  • LocalAudioTrack
  • RemoteAudioTrack
  • MediaStreamTrack
If you pass an SDK Track, the recorder listens for internal media track replacement events and automatically switches to the new track when a reconnect or resubscription changes the underlying MediaStreamTrack, with no action needed from your app.

Layout responsibility

LocalCompositeRecorder has no built-in call layout algorithm. Your app should generate videoItems based on the current UI view:
  • If only 3 users are shown right now, pass only those 3 video items.
  • If it’s a 9-tile grid, compute rect for 9 slots.
  • After the user pages left or right, call updateVideoItems(...) to switch to the new page.
  • Special layouts such as screen sharing or speaker mode also have their rect computed by your app.
This way the recording follows the current view passed in by your app, rather than always recording all remote streams.

Audio recommendations

For call recording, we generally recommend passing in both the local microphone track and the remote mixed audio track:
To record only remote audio, pass only remoteAudioMixTrack; to record only the local microphone, pass only localMicTrack.

Upload while recording

Pass timeslice and onDataAvailable to get data in chunks in real time, for uploading or writing to disk while recording, so long recordings don’t take up a lot of memory:
Note: webm chunks are a streaming container; a single chunk usually can’t be played on its own, and the server needs to concatenate them in order into a complete file.

State and cleanup


Notes

  • Must run over HTTPS (or localhost); AudioContext may need a user gesture before it can start.
  • The output format is webm; browsers support different codecs (vp9/vp8/opus), and the SDK falls back to an available format automatically.
  • pause / resume apply to the same final file and don’t produce multiple files.
  • The higher the recording resolution and frame rate, the higher the CPU usage; choose width/height/fps to suit your scenario.