Track Egress

Track Egress allows you export a single track without transcoding.


TrackEgress is the simplest way to export individual tracks to cloud storage or a server via WebSocket.

Tracks are exported as is, without transcoding. The following containers will be used depending on track codec:

  • H.264: MP4
  • VP8: WebM
  • Opus: Ogg

Note: Track Egress only exports one track, either video or audio. If you want to export video and audio together, use Track Composite Egress.

Export to cloud storage

const output = new DirectFileOutput({
filepath: 'livekit-demo/track-test.mp4',
output: {
case: 's3',
value: new S3Upload({
accessKey: 'aws-access-key',
secret: 'aws-access-secret',
bucket: 'my-bucket',
const info = await egressClient.startTrackEgress('my-room', output, trackID);
const egressID = info.egressId;

Stream audio to WebSocket

You can add custom stream processing by starting a TrackEgress to your WebSocket server. This will give you a realtime streaming export of your audio tracks. (WebSocket streaming is only available for audio tracks).

The tracks will be exported as raw PCM data. This format is compatible with most transcription services.

  • Format: pcm_s16le
  • Content-Type: audio/x-raw
  • Sample rate: matches incoming, typically 48kHz

When a TrackEgressRequest is started with a WebSocket URL, we'll initiate a WebSocket session to the designated URL. We recommend using query parameters in the URL in order to help you identify the track. For example: wss://<trackID>&participant=<participantIdentity>

We'll send a combination of binary and text frames. Binary frames would contain audio data. Text frames will contain end user events on the tracks. For example: if the track was muted, you will receive the following:

{ "muted": true }

And when unmuted:

{ "muted": false }

The WebSocket connection will terminate when the track is unpublished (or if the participant leaves the room).

const info = await egressClient.startTrackEgress(
const egressID = info.egressId;