how to start room composite egress request in js?
# ask-ai
l
how to start room composite egress request in js?
t
Thanks for reaching out, Piyush. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To start a room composite egress request in JavaScript, you can use the
startRoomCompositeEgress
method from LiveKit's EgressClient. Here's an example:
Copy code
const { EgressClient, SegmentedFileOutput, EncodingOptionsPreset, SegmentedFileProtocol } = require('@livekit/protocol');

// Initialize the Egress client with your LiveKit host and credentials
const egressClient = new EgressClient(
  '<http://your-livekit-server.io|your-livekit-server.io>',
  'your-api-key',
  'your-api-secret'
);

// Define the output configuration (e.g., for HLS segments)
const segmentedOutput = new SegmentedFileOutput({
  filenamePrefix: 'livekit-demo/room-composite-test-',
  playlistName: 'room-composite-test.m3u8',
  segmentDuration: 6,
  protocol: SegmentedFileProtocol.HLS_PROTOCOL,
  preset: EncodingOptionsPreset.PORTRAIT_H264_720P_30,
});

// Start the room composite egress
const info = await egressClient.startRoomCompositeEgress('my-room', {
  segments: segmentedOutput
});

// Get the egress ID for further operations
const egressId = info.egressId;
Key Points:roomName: Specify the name of the room to record. • Output Configuration: Use
SegmentedFileOutput
for HLS or other formats like
EncodedFileOutput
or
StreamOutput
. • Options: Configure layout, audio-only, video-only, or custom base URLs as needed. Ensure your Egress client has the necessary permissions, such as
roomRecord
. Let me know if you need further assistance!