I want to record both the room egress and just the...
# ask-ai
a
I want to record both the room egress and just the sound tracks. both recording should be saved
t
Thanks for reaching out, Anne. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
If you want to record both the whole room’s audio and video, as well as individual audio tracks in LiveKit, here are a couple of ways you can do it: • Room Composite Egress: This captures everything happening in the room together. You can set it up to save the recording to a file or even stream it live. • Track Egress: This lets you record specific audio tracks one by one. Just pick the track IDs you want to capture. You can actually run both methods at the same time to get exactly what you need. If you’d like, I’m happy to share detailed steps or some code examples to help you get started! Sources: Recording and composition | LiveKit Docs | Recording Participants | LiveKit Docs | protobufs/livekit_egress.proto | packages/livekit-server-sdk/src/EgressClient.ts | Auto egress | LiveKit Docs
a
yes please how do I run both? Currently I create a room like so room_request = livekit_api.CreateRoomRequest( name=room_name, empty_timeout=600, # 10 minutes max_participants=10, metadata=metadata_json, egress=livekit_api.RoomEgress( room=livekit_api.RoomCompositeEgressRequest( file_outputs=[ livekit_api.EncodedFileOutput( filepath=f"{room_name}.mp4", s3=livekit_api.S3Upload( access_key=config.s3_upload_access_key, secret=config.s3_upload_secret, bucket=metadata.interview_recording_bucket, region="us-east-1", ), ) ] ) ), )
t
Hey there! If you want to run both room composite egress and track egress at the same time in LiveKit, you’ll just need to make separate API calls for each one. Here’s a simple way to do it using Python:
Copy code
import asyncio

# Start room composite egress
room_egress_task = egress_service.start_room_composite_egress(
    RoomCompositeEgressRequest(
        room_name="my-room",
        file_outputs=[EncodedFileOutput(filepath="room-{time}.mp4")]
    )
)

# Start track egress
track_egress_task = egress_service.start_track_egress(
    TrackEgressRequest(
        room_name="my-room",
        track_id="track-id", 
        file=DirectFileOutput(filepath="track-{time}.mp4")
    )
)

# Wait for both to start
room_info, track_info = await asyncio.gather(
    room_egress_task, 
    track_egress_task
)
Just a heads-up: each egress will have its own unique ID, and since they run independently, make sure your server can handle both at once. If you hit any bumps or want to chat more about this, I’m here to help! Sources: pkg/service/egress.go | packages/livekit-server-sdk/src/EgressClient.ts | src/test/kotlin/io/livekit/server/EgressServiceClientTest.kt | livekit-api/livekit/api/egress_service.py | protobufs/livekit_egress.proto
a
how do I know the "track-id"
t
Hey there! If you’re looking to find the "track-id" for a specific audio or video track in LiveKit, here are a few easy ways to do it: • From TrackPublication: If you have the track publication handy, just grab the
sid
field—that’s the unique ID for the track. For example:
trackId = trackPublication.sid
. • Server API: You can also use the LiveKit server API to list all participants and their tracks. This will give you the track IDs for every track in the room. • By Name or Source: If you know the track’s name or source, you can find the track publication and then get its
sid
. If you want, I’m happy to walk you through any of these methods step-by-step—just let me know! Sources: Universal Egress | libwebrtc/src/media_stream.rs | findMicroTrackId | LiveKit Agents | lib/src/types/track_identifier.dart | Core API primitives | LiveKit Docs