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 = new EncodedFileOutput({fileType: EncodedFileType.MP4,filepath: 'livekit-demo/track-composite-test.mp4',output: {case: 's3',value: new S3Upload({accessKey: 'aws-access-key',secret: 'aws-access-secret',bucket: 'my-bucket',}),},});const info = await egressClient.startTrackCompositeEgress('my-room',{ file: output },{audioTrackId,videoTrackId,},);const egressID = info.egressId;
Supported Outputs
TrackComposite supports the same output methods as RoomComposite: RTMP, MP4, HLS and Images. Refer to RoomComposite examples for additional details.