lively-terabyte-73999
08/05/2025, 7:22 AMtall-airline-16756
08/05/2025, 7:22 AMtall-airline-16756
08/05/2025, 7:22 AMParticipantEgressRequest struct to specify the room name, participant identity, and other options like encoding and file outputs.
2. Call the StartParticipantEgress method on the Egress client with your request. This will return an EgressInfo object containing details about the started egress.
Here is an example in Python:
from livekit.protocol.egress import (
ParticipantEgressRequest,
EncodedFileOutput,
S3Upload,
EncodingOptionsPreset,
)
from livekit.api import LiveKitAPI
# Initialize the LiveKit API client
lk = LiveKitAPI(api_key="your_api_key", api_secret="your_api_secret")
# Create an S3 upload configuration
s3_config = S3Upload(
access_key="your_access_key",
secret="your_secret_key",
region="your_bucket_region",
bucket="your_bucket_name",
)
# Create the file output configuration for MP4
file_output = EncodedFileOutput(
filepath="participant-recording.mp4",
file_type=EncodedFileType.MP4,
s3=s3_config,
)
# Create the ParticipantEgressRequest
request = ParticipantEgressRequest(
room_name="your_room_name",
identity="participant_identity",
screen_share=False,
options=EncodingOptionsPreset.H264_720P_30,
file_outputs=[file_output],
)
# Start the participant egress
egress_info = lk.egress.start_participant_egress(request)
print(f"Egress Started: {egress_info}")
This example demonstrates how to configure and start a participant egress for audio recording. Let me know if you need further assistance!
Sources: Recording participants | LiveKit Docs | protobufs/livekit_egress.protolively-terabyte-73999
08/05/2025, 7:23 AMtall-airline-16756
08/05/2025, 7:23 AMlively-terabyte-73999
08/05/2025, 7:24 AMtall-airline-16756
08/05/2025, 7:25 AMCreateRoomRequest. Specifically, the RoomEgress field is where you set up automatic participant egress.
Here’s a quick example of how your request might look:
{
"name": "my-room",
"egress": {
"participant": {
"fileOutputs": [...],
"segmentOutputs": [...],
"options": {
// participant egress options
}
}
}
}
Once you’ve got auto participant egress set up, the system will automatically start participant egress as soon as participants join the room—so you don’t have to worry about setting it up manually after creating the room.
If you want, I’m here to help with any more details or questions you have about the setup!
Sources: livekit/livekit_room.pb.go | cmd/lk/egress.go | Auto Egress | LiveKit Docs | pkg/rtc/egress.golively-terabyte-73999
08/05/2025, 7:27 AMtall-airline-16756
08/05/2025, 7:28 AMAutoParticipantEgress settings. Here’s an example:
{
"filepath": "<s3://my-bucket/{room_name}-{participant_identity}-{timestamp}>",
"s3": {
"access_key": "YOUR_AWS_ACCESS_KEY",
"secret": "YOUR_AWS_SECRET_KEY",
"bucket": "my-bucket",
"region": "us-east-1"
}
}
- The filepath is where your recorded files will be saved.
- The s3 section holds your AWS credentials and configuration details.
2. Use the Configuration File When Creating a Room
When you create a room, just point to this JSON file using the --participant-egress-file flag. Here’s the CLI command you’d use:
lk room create my-room --participant-egress-file examples/auto-participant-egress.json
- Make sure to replace auto-participant-egress.json with the path to your actual JSON file.
- This command will create a room with auto participant egress turned on.
3. Programmatic Example (Go)
If you’re working with the LiveKit Go SDK, here’s how you can set up auto participant egress programmatically:
import (
"context"
"<http://github.com/livekit/protocol/livekit|github.com/livekit/protocol/livekit>"
lksdk "<http://github.com/livekit/server-sdk-go/v2|github.com/livekit/server-sdk-go/v2>"
)
func createRoomWithEgress() error {
ctx := context.Background()
client := lksdk.NewRoomServiceClient("your-server-url")
egressConfig := &livekit.AutoParticipantEgress{
FileOutputs: []*livekit.DirectFileOutput{{
Filepath: "<s3://my-bucket/{room_name}-{participant_identity}-{timestamp}>",
Output: &livekit.DirectFileOutput_S3{
S3: &livekit.S3Output{
Bucket: "my-bucket",
AccessKey: "YOUR_AWS_ACCESS_KEY",
Secret: "YOUR_AWS_SECRET_KEY",
Region: "us-east-1",
},
},
}},
}
req := &livekit.CreateRoomRequest{
Name: "my-room",
Egress: &livekit.RoomEgress{
Participant: egressConfig,
},
}
_, err := client.CreateRoom(ctx, req)
return err
}
This setup tells LiveKit to automatically record all participant sessions and save them right into your specified S3 bucket.
If you have any questions or want me to walk you through more examples, just let me know—I’m here to help!
Sources: livekit/livekit_room.pb.go | cmd/lk/room.golively-terabyte-73999
08/05/2025, 7:30 AMtall-airline-16756
08/05/2025, 7:30 AMlively-terabyte-73999
08/05/2025, 10:07 AM