<@U08CKJH7C12> I could really use help with allowi...
# egress
a
@refined-appointment-81829 I could really use help with allowing participant's audio + video egress . the following code runs but I dont see the egress happening when i do a
python agent.py dev
the code :
Copy code
# Get GCP credentials from credentials.json file.
    file_contents = ""
    cwd = os.getcwd()
    with open(f"{cwd}\\testing-457806-15f9c1d813b1.json", "r") as f:
      file_contents = f.read()
    
    req = api.ParticipantEgressRequest(
        room_name=ctx.room.name,
        identity=user_identity,
        preset=api.EncodingOptionsPreset.H264_720P_30,
        file_outputs=[api.EncodedFileOutput(
            file_type=api.EncodedFileType.MP4,
            filepath="livekit/my-room-test.mp4",
            gcp=api.GCPUpload(
                bucket="session_recordings",
                credentials=file_contents,
            ),
        )],
    )

    lkapi = api.LiveKitAPI()
    res = await lkapi.egress.start_participant_egress(req)

    await lkapi.aclose()
Edit: I realized i hadnt called the stop_egress(). but even after doing that i end up with an error :
Copy code
print(f"🔔 Attempting to close egress {egress_id}")
lkapi = api.LiveKitAPI()
stop_req = api.StopEgressRequest(egress_id=egress_id)
res = await lkapi.egress.stop_egress(stop=stop_req)
print(f"🔔Egress info :{str(res)}")
await lkapi.aclose()
print("Egress CLOSED")
the error :
Copy code
{"message": "skipping user input, speech scheduling is paused", "level": "WARNING", "name": "livekit.agents", "user_input": "okay l sheet is something that used to style web pages", "timestamp": "2025-09-23T14:25:52.516432+00:00"}
Error while ending :  TwirpError(code=failed_precondition, message=egress with status EGRESS_FAILED cannot be stopped, status=412)
{"message": "Unclosed client session\nclient_session: aiohttp.client.ClientSession object at 0x000001CD66B46AD0", "level": "ERROR", "name": "asyncio", "timestamp": "2025-09-23T14:25:56.123995+00:00"}
{"message": "Unclosed connector\nconnections: ['deque([(aiohttp.client_proto.ResponseHandler object at 0x000001CD69DD74D0, 5644.1847667)])']\nconnector: aiohttp.connector.TCPConnector object at 0x000001CD66B58E90", "level": "ERROR", "name": "asyncio", "timestamp": "2025-09-23T14:25:56.124823+00:00"}
{"message": "livekit::rtc_engine:453:livekit::rtc_engine - received session close: \"signal client closed: \\\"stream closed\\\"\" UnknownReason Resume", "level": "WARNING", "name": "livekit", "timestamp": "2025-09-23T14:26:11.871583+00:00"}
and this is the egrees info object i got when i started the egress.
Copy code
room_id: "RM_dNpbDGVaPSU2"
file {
  filename: "livekit/my-room-test.mp4"
}
started_at: 1758637524410853589
room_name: "scheduled_2_18--room-869e47f3"
file_results {
  filename: "livekit/my-room-test.mp4"
}
updated_at: 1758637524410853589
participant {
  room_name: "scheduled_2_18--room-869e47f3"
  identity: "testing@gmail.com"
  preset: H264_720P_30
  file_outputs {
    file_type: MP4
    filepath: "livekit/my-room-test.mp4"
    gcp {
      credentials: "{credentials}"
      bucket: "session_recordings"
    }
  }
}