Guides / Recording & Livestreaming / Track Composite

Track Composite

Overview

TrackComposite combines a video and an audio tracks together, outputing as a MP4, HLS, or RTMP stream. In order to resolve encoding differences from the WebRTC session, TrackComposite will transcode input streams to an encoding that's suitable for the output container.

TrackComposite Egress handles tricky scenarios such as synchronization, or if one of the tracks has been muted by the user.

Currently TrackComposite is the method to use in order to export a single participant's audio and video together.

Usage

In order to use a TrackComposite, you need to know the TrackID of an audio and video track. This can be obtained either from the client SDK, or the TrackPublished webhook.

const output = {
fileType: EncodedFileType.MP4,
filepath: 'livekit-demo/track-composite-test.mp4',
s3: {
accessKey: 'aws-access-key',
secret: 'aws-access-secret',
region: 'aws-region',
bucket: 'my-bucket'
}
};
const info = await egressClient.startTrackCompositeEgress('my-room', output, audioTrackID, videoTrackID);
const egressID = info.egressId;

Supported Outputs

TrackComposite supports the same output methods as RoomComposite: RTMP, MP4, and HLS. Refer to RoomComposite examples for additional details.