wooden-magazine-46516
10/24/2025, 11:35 AMtall-airline-16756
10/24/2025, 11:35 AMtall-airline-16756
10/24/2025, 11:36 AMstreamRequest := &livekit.RoomCompositeEgressRequest{
RoomName: "my-room",
Layout: "speaker-dark",
Output: &livekit.RoomCompositeEgressRequest_Stream{
Stream: &livekit.StreamOutput{
Protocol: livekit.StreamProtocol_RTMP,
Urls: []string{"rtmp://live.twitch.tv/app/<stream-key>"},
},
},
}
• Track Composite Egress: This method exports synchronized audio and video tracks from a single participant. For instance, you can save it as an MP4 file in S3 storage like this:
{
"room_name": "my-room",
"audio_track_id": "TR_XXXXXXXXXXXX",
"video_track_id": "TR_XXXXXXXXXXXX",
"file": {
"file_type": "MP4",
"filepath": "livekit-demo/track-composite-test.mp4",
"s3": {
"access_key": "aws-access-key",
"secret": "aws-access-secret",
"region": "aws-region",
"bucket": "my-bucket"
}
}
}
• Track Egress: This allows you to export individual audio or video tracks either as files or streams.
You can get started with these using our server SDKs (Go, JS, Python, and more), CLI, or REST APIs. If you’d like, I’m here to help you with any specific method or setup you want to try—just let me know!
Sources: Recording and export | LiveKit Docs | Universal Egress | README.md | Universal Egress | cmd/lk/examples/track-composite-file.jsonwooden-magazine-46516
10/24/2025, 11:45 AMtall-airline-16756
10/24/2025, 11:45 AMegress_info = await egress.start_room_composite_egress(
room_name="my-room",
layout="grid",
file_outputs=[EncodedFileOutput(filepath="output.mp4", s3=s3_config)]
)
1. Register a Shutdown Callback: To make sure recording stops when the session ends, you can use a callback like this:
def on_shutdown():
await egress.stop_egress(egress_id=egress_info.egress_id)
ctx.add_shutdown_callback(on_shutdown)
1. Ensure Proper Configuration: If you’re working with a self-hosted setup, don’t forget to configure the egress.yaml file with your storage credentials. If you’re using LiveKit Cloud, you’re all set to use egress without extra setup.
2. Monitor Egress Status: After stopping egress, it’s a good idea to check that the recording uploaded successfully by using list_egress.
If you’d like, I’m here to help you with implementing this or tweaking any specific egress options to fit your needs. Just let me know!
Sources: pkg/server/server.go | Recording and export | LiveKit Docs | livekit-api/livekit/api/egress_service.py | lib/livekit/proto/livekit_egress_pb.rb | docs/index.yamlwooden-magazine-46516
10/24/2025, 12:01 PMtall-airline-16756
10/24/2025, 12:01 PMegress module isn’t included in the livekit.agents package. The egress features, like recording and exporting media, are actually part of the LiveKit Python Server SDK, not the Agents SDK.
To get those egress capabilities up and running, you’ll want to install and use the LiveKit Python Server SDK. Here’s a friendly example to help you start a Room Composite Egress:
from livekit.api import LiveKitAPI
from livekit.protocol.egress import RoomCompositeEgressRequest, EncodedFileOutput, S3Upload
api = LiveKitAPI("your-api-key", "your-api-secret", "https://your-livekit-server")
request = RoomCompositeEgressRequest(
room_name="my-room",
file_outputs=[
EncodedFileOutput(
filepath="recordings/my-recording.mp4",
s3=S3Upload(
access_key="your-access-key",
secret="your-secret",
region="us-west-2",
bucket="your-bucket"
)
)
]
)
result = await api.egress.start_room_composite_egress(request)
print(f"Egress started: {result.egress_id}")
If you’d like, I’m here to help you set up the Python Server SDK or walk you through configuring the egress options—just let me know!
Sources: livekit-protocol/livekit/protocol/egress.pyi | Egress examples | LiveKit Docs | Egress API | LiveKit Docs | livekit-agents/livekit/agents/__init__.pywooden-magazine-46516
10/24/2025, 12:20 PMtall-airline-16756
10/24/2025, 12:22 PMoutput field is being mistakenly treated as a oneof group instead of a regular field. In LiveKit's protocol, output is actually a standard string field, not a oneof.
Here are some friendly steps to help you resolve this:
1. Check Field Access: Make sure you’re accessing output directly, like functionCallOutput.Output, rather than through any oneof handling.
2. Verify Message Construction: When you’re building your FunctionCallOutput, try using direct field assignment like this:
functionOutput = FunctionCallOutput(
output="result_value",
is_error=False
)
1. Review Agent Configuration: Double-check that the agent name is consistent between your worker options and dispatch rules.
2. Check SDK Compatibility: It’s a good idea to confirm that your protobuf-generated code aligns with the expected LiveKit protocol version.
If you’d like, I’m here to help you debug this further—just let me know!
Sources: livekit/agent/livekit_agent_session.pb.go | Runtime/Scripts/Proto/Ffi.cs | livekit-agents/livekit/agents/voice/run_result.py | SIP troubleshooting guide | LiveKit Docswooden-magazine-46516
10/24/2025, 12:29 PMtall-airline-16756
10/24/2025, 12:30 PMfile_outputs field in RoomCompositeEgressRequest is expecting an iterable, like a list, rather than a single object. No worries though! You can easily fix this by wrapping your EncodedFileOutput inside a list, like this:
from livekit.protocol import egress
# Create your file output
file_output = egress.EncodedFileOutput(
filepath="my-recording.mp4",
# ... other configuration
)
# Create the request with file_outputs as a list
request = egress.RoomCompositeEgressRequest(
room_name="my-room",
layout="grid",
file_outputs=[file_output] # Just add the square brackets here
)
This approach is the same for all output fields, such as stream_outputs and segment_outputs, which also expect iterables even if you’re only providing a single output configuration. If you have any more questions or need a hand with this, feel free to ask—I’m here to help!
Sources: livekit-protocol/livekit/protocol/room.pyi | Egress output types | LiveKit Docswooden-magazine-46516
10/24/2025, 12:33 PMtall-airline-16756
10/24/2025, 12:34 PMoutput field in your RoomCompositeEgressRequest is either missing or not set up quite right. Don’t worry, I’m here to help you get this sorted out! Here’s what you can do:
1. Make Sure the Output Field is Included: Your request needs to have at least one output field like file_outputs, stream_outputs, or segment_outputs. For example:
from livekit.protocol import egress
file_output = egress.EncodedFileOutput(
filepath="my-recording.mp4",
s3=egress.S3Upload(
access_key="your-access-key",
secret="your-secret",
region="us-west-2",
bucket="your-bucket"
)
)
request = egress.RoomCompositeEgressRequest(
room_name="my-room",
layout="grid",
file_outputs=[file_output] # Make sure this is a list
)
1. Double-Check Your Output Settings: It’s important to provide all required details for the type of output you’re using:
• File Outputs: Include a valid storage destination like S3, GCP, or Azure.
• Stream Outputs: Make sure there’s at least one URL and a supported protocol such as RTMP.
• Segment Outputs: Don’t forget storage setup and any optional HLS settings.
1. Review Your Encoding Options: Use either preset or advanced encoding options, but avoid using both at the same time.
If you’d like, I’m happy to walk you through any of these steps or answer any questions you have. Just let me know!
Sources: livekit-protocol/livekit/protocol/egress.pyi | livekit/livekit_egress.pb.go | packages/livekit-server-sdk/src/EgressClient.ts | RoomComposite Egress | LiveKit Docs | Universal Egresswooden-magazine-46516
10/24/2025, 12:38 PMtall-airline-16756
10/24/2025, 12:38 PMEncodedFileOutput with a local file path. Here’s a simple example to guide you:
from livekit.protocol import egress
# Create a file output with a local file path
file_output = egress.EncodedFileOutput(
filepath="/path/to/local/directory/my-recording.mp4" # Replace with your desired local path
)
# Create the RoomCompositeEgressRequest
request = egress.RoomCompositeEgressRequest(
room_name="my-room",
layout="grid",
file_outputs=[file_output] # Ensure this is a list
)
Just make sure your application has permission to write to the folder you specify. If you run into any trouble or have questions, feel free to reach out—I’m here to help!wooden-magazine-46516
10/24/2025, 12:39 PMtall-airline-16756
10/24/2025, 12:39 PMfrom livekit.api import LiveKitAPI
from livekit.protocol.egress import RoomCompositeEgressRequest, EncodedFileOutput
# Initialize the LiveKit API
api = LiveKitAPI("your-api-key", "your-api-secret", "https://your-livekit-server")
# Define the local file output
file_output = EncodedFileOutput(
filepath="/path/to/local/directory/my-recording.mp4" # Replace with your desired local path
)
# Create the RoomCompositeEgressRequest
req = RoomCompositeEgressRequest(
room_name=ctx.room.name, # Ensure ctx.room.name is correctly set
layout="grid", # Can also be "speaker"
file_outputs=[file_output] # Wrap the file output in a list
)
# Start the egress
egress_info = await api.egress.start_room_composite_egress(req)
print(f"Egress started: {egress_info.egress_id}")
Just a couple of things to keep in mind:
• Make sure that the ctx.room.name variable has the correct room name so everything runs smoothly.
• Check that your application has the right permissions to write to the local directory you specified.
• Don't forget to replace your-api-key, your-api-secret, and https://your-livekit-server with your actual LiveKit credentials and server URL.
If you have any questions or need a hand with anything else, just let me know—I’m here to help!wooden-magazine-46516
10/24/2025, 12:45 PMtall-airline-16756
10/24/2025, 12:45 PMaiohttp.client_exceptions.InvalidUrlClientError is happening because the URL you provided to the LiveKitAPI isn’t quite right. The URL seems incomplete or a bit off (for example, ::///APIkrteiw2gwcFk/twirp/livekit.Egress/StartRoomCompositeEgress).
Here’s a friendly guide to help you fix this:
1. Make sure you’re giving a valid LiveKit server URL when you set up the LiveKitAPI. Something like this works well:
api = LiveKitAPI(
"your-api-key",
"your-api-secret",
"https://your-livekit-server" # Just swap this with your real server URL
)
1. Double-check that your server URL includes the protocol part (like https:// or http://).
2. Take a moment to look for any typos or missing pieces in the URL.
If you’d like, I’m here to help you step-by-step with setting up the API client—just let me know!
Sources: livekit-api/livekit/api/sip_service.pywooden-magazine-46516
10/24/2025, 12:49 PMtall-airline-16756
10/24/2025, 12:49 PMwooden-magazine-46516
10/24/2025, 1:50 PMwooden-magazine-46516
10/24/2025, 1:55 PMwooden-magazine-46516
10/30/2025, 11:57 PM