From 1c11c345122cbdfa294f217b958f8e1884df5a8f Mon Sep 17 00:00:00 2001 From: David Colburn Date: Sun, 26 Jul 2026 09:39:42 -0400 Subject: [PATCH] python server SDK: add unified start_egress convenience method livekit-api (python) EgressService exposes a unified start_egress that calls the Egress.StartEgress RPC with the v2 StartEgressRequest --- livekit-api/livekit/api/egress_service.py | 11 +++++++++++ tests/api/test_livekitapi.py | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/livekit-api/livekit/api/egress_service.py b/livekit-api/livekit/api/egress_service.py index 12f81c3e..5a3065f2 100644 --- a/livekit-api/livekit/api/egress_service.py +++ b/livekit-api/livekit/api/egress_service.py @@ -9,6 +9,7 @@ UpdateStreamRequest, ListEgressRequest, StopEgressRequest, + StartEgressRequest, EgressInfo, ListEgressResponse, ) @@ -93,6 +94,16 @@ async def start_track_egress(self, start: TrackEgressRequest) -> EgressInfo: EgressInfo, ) + async def start_egress(self, start: StartEgressRequest) -> EgressInfo: + """Starts an egress; the request's source and outputs determine the egress type.""" + return await self._client.request( + SVC, + "StartEgress", + start, + self._auth_header(VideoGrants(room_record=True)), + EgressInfo, + ) + async def update_layout(self, update: UpdateLayoutRequest) -> EgressInfo: """Updates the layout of a composite recording.""" return await self._client.request( diff --git a/tests/api/test_livekitapi.py b/tests/api/test_livekitapi.py index 3ce1ead2..f84bfa48 100644 --- a/tests/api/test_livekitapi.py +++ b/tests/api/test_livekitapi.py @@ -194,6 +194,19 @@ async def _egress_smoke(): file=api.DirectFileOutput(filepath="track.mp4"), ) ) + await lk.egress.start_egress( + api.StartEgressRequest( + room_name="test-room", + web=api.WebSource(url="https://example.com/scene"), + outputs=[ + api.Output( + file=api.FileOutput( + file_type=api.EncodedFileType.MP4, filepath="unified.mp4" + ) + ) + ], + ) + ) await lk.egress.update_layout( api.UpdateLayoutRequest(egress_id="EG_abc123", layout="speaker") )