How do i force to start egress recording using liv...
# ask-ai
r
How do i force to start egress recording using livekit-server-sdk 2.13.1
t
Thanks for reaching out, Bil. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! Could you please help me understand a bit more about what you mean by "force start" for egress recording? Are you hoping to: • Start recording right away without waiting for participants? (This usually happens by default) • Bypass some kind of validation or safety check? • Begin recording even if the room hasn’t been created yet? • Restart a recording session that didn’t start properly? • Set up recording to start at a specific time? If you could share a few more details, I’ll be able to assist you much better. Looking forward to your reply! Sources: protobufs/livekit_egress.proto | Egress examples | LiveKit docs | lib/livekit/egress_service_client.rb | pkg/service/egress.go
r
I'm using the awaitStartSignal but await EGRESS_CLIENT.updateEgress(
EG_JuwiXTjYMGxo
, { action: 'start' }); didn't work
t
Thanks for your question! The
awaitStartSignal
parameter is there to help delay the start of recording until a specific signal (like
START_RECORDING
) is detected. It’s a handy feature to have that control. However, just a heads-up—the
updateEgress
method with the action 'start' isn’t actually meant to kick off the recording. Instead, you’ll want to start egress first using one of the
Start...Egress
methods, such as
StartWebEgress
. Once your egress session is up and running, you can definitely use
updateEgress
to tweak your streaming outputs on the fly, but starting the recording itself needs that initial start method. Also, make sure your access token has the
roomRecord
permission so everything works smoothly. If any of this feels a bit tricky or if you’d like me to walk you through starting egress or using
awaitStartSignal
, just give me a shout—I’m here to help! Sources: lib/livekit/egress_service_client.rb | src/main/kotlin/io/livekit/server/EgressServiceClient.kt | cmd/lk/egress.go | livekit-api/livekit/api/egress_service.py | Egress API | LiveKit docs
r
whats the difference between startWebEgress and startTrackEgress
t
I'm glad you asked about the difference between
startWebEgress
and
startTrackEgress
! Let me walk you through it in a simple way, so it’s easy to understand: • startWebEgress: ◦ Purpose: This one helps you capture and record or stream any website by using a headless Chromium instance. ◦ Input Source: You just need to provide a URL, and it will render and capture the webpage content for you. ◦ Use Case: It’s perfect when you want to record website content that isn’t connected to a LiveKit room. Its lifecycle works independently from LiveKit rooms. ◦ Output Options: You have several options here, like encoded file outputs (such as MP4), segmented files, streams, and even images. • startTrackEgress: ◦ Purpose: This one is designed to export individual audio or video tracks from a LiveKit room, sending them directly to cloud storage or a WebSocket server without any transcoding. ◦ Input Source: You’ll need a specific track ID from a participant in the room to get started. ◦ Use Case: It’s the best choice if you want to export raw, unprocessed tracks. Just keep in mind it exports one track at a time, whether audio or video. ◦ Output Format: The tracks are exported in their original format—H.264 as MP4, VP8 as WebM, and Opus as Ogg. For audio streaming through WebSocket, it sends raw PCM data. To sum it up,
startWebEgress
is your go-to for capturing web content outside of LiveKit rooms, while
startTrackEgress
is tailored for exporting individual, raw media tracks from participants inside a LiveKit room. I hope this clears things up! If you have any more questions, feel free to ask—I’m here to help. Sources: Web Egress | LiveKit Docs | lib/livekit/proto/livekit_egress_twirp.rb | Track egress | LiveKit docs
r
Please confirm if the startWebEgress is the method need to use when implementin custom recording template.
t
I'm glad you're exploring how to implement a custom recording template for a LiveKit room! To do this, the best approach is to use
StartRoomCompositeEgress
with the
custom_base_url
parameter. This lets you specify a custom web application that beautifully renders the room's participants exactly how you'd like. You might be wondering, why not use
startWebEgress
?
•
startWebEgress
is mainly meant for recording static web pages and doesn’t dynamically connect to LiveKit rooms. It won’t automatically render participants unless you manually integrate it, which isn’t the recommended path here. Here’s a simple way to set up your custom recording template: 1. Create your custom frontend using the LiveKit template SDK. 2. Deploy your frontend to a public URL. 3. Use
StartRoomCompositeEgress
with the
custom_base_url
pointing to your deployed template. This approach ensures everything works smoothly with LiveKit’s egress lifecycle and participant rendering. If you have any questions or need a hand along the way, just let me know—I’m here to help! Sources: Web Egress | LiveKit Docs | Custom recording templates | LiveKit docs | src/main/kotlin/io/livekit/server/EgressServiceClient.kt | livekit-api/livekit/api/egress_service.py | lib/livekit/egress_service_client.rb
r
Then why my custom recording template didn't start recording? When i validate my egress info status = 0 and error = '' and errorCode: 0 it means that the egress is not recording right? Why my egress got EGRESS_ABORTED status and this is the reason "End reason: StopEgress API. Stop called before pipeline could start". I also added a START_RECORDING log in custom template html. No error where found but mux didn't received any egress data
t
I understand how encountering the status
EGRESS_ABORTED
with the reason "Stop called before pipeline could start" can be a bit confusing. This usually happens when the
StopEgress
API is called before the egress pipeline has had a chance to move from
EGRESS_STARTING
to
EGRESS_ACTIVE
. Often, this is due to calling
StopEgress
too early, which might be caused by logic hiccups, race conditions, or event handling that’s not quite aligned yet. Let’s walk through some steps together to help you troubleshoot and resolve this: 1. First, please check that
StopEgress
isn’t being triggered immediately after starting the egress. Taking another look at your application logic to prevent early stop signals can make a big difference. 2. Next, make sure your custom template is correctly sending the
START_RECORDING
signal. This step is important because it helps the egress move from
EGRESS_STARTING
to
EGRESS_ACTIVE
. 3. It’s also helpful to consider any network delays or resource allocation times that might be extending the
EGRESS_STARTING
phase, as this could create a bigger window for an early stop call. 4. Using the
ListEgress
API or webhooks to keep an eye on the egress status can ensure it reaches
EGRESS_ACTIVE
before you proceed with other actions. If you notice that your custom template isn’t sending data to Mux, double-check that the
START_RECORDING
log is being executed and that your template is set up correctly to connect to the LiveKit room and render participants. Please don’t hesitate to reach out if you’d like more help debugging your custom template or egress setup—I’m here to support you! Sources: pkg/handler/handler_rpc.go | cmd/lk/egress.go | Egress API | LiveKit docs