SIP Phone Call로 Agent와 대화시 1. make_call 2. wait_fo...
# ask-ai
l
SIP Phone Call로 Agent와 대화시 1. make_call 2. wait_for_participant 3. Set up room composite egress for recording to AWS S3 4. ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY) 5. shutdown_callback => egress aclose() 로 종료 이 순서로 오디오 녹음을 하여 S3로 업로드 과정으로 되어 있는데, 음성파일을 들어보면 통화종료후에도 약 20초가량 더 음성이 이어지는데, 이유가 뭐고 어떻게 수정할수 있을까?
t
Thanks for reaching out, Dan(송희웅). I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! I understand it might be a bit surprising that the audio recording continues for about 20 seconds after the call ends. This happens because the egress participant, who handles the recording, stays in the room briefly even after the human participant leaves. This is actually the default behavior of Room Composite Egress—it only stops once everyone has left the room. If you'd like to stop the recording right when the call ends, here are a couple of ways you can do that: • Delete the room: This will make the egress participant exit immediately and stop the recording. • Manually stop the egress: You can use the
stopEgress
API to end the recording whenever you want. Usually, deleting the room as soon as the call ends is the best way to make sure no extra audio gets recorded. Also, if you’re using custom egress templates or have specific server-side settings, those might affect how quickly the recording stops. Please feel free to reach out if you want help setting this up or have any other questions—I’m here to help! Sources: Composite and web recordings | LiveKit Docs | Custom recording templates | LiveKit Docs | README.md
l
• Start Recording lkapi = api.LiveKitAPI() await lkapi.egress.start_room_composite_egress(req) • Stop Recroing ctx.shutdown_callback 안에서 await lkapi.aclose() <= 이 코드로 "*Manually stop the egress*" 하는거 아니야?
t
I understand that using
await lkapi.aclose()
inside
ctx.shutdown_callback
might feel like it should stop the egress, but it actually just closes the LiveKit API client session and frees up resources. It doesn't automatically stop an active egress recording. To make sure the egress recording stops properly, you’ll want to explicitly call the
stop_egress
API with the right egress ID. Here’s a simple example you can follow:
Copy code
async def cleanup():
    await lkapi.egress.stop_egress(api.StopEgressRequest(egress_id=res.egress_id))
    await lkapi.aclose()

ctx.add_shutdown_callback(cleanup)
This way, your recording will be properly stopped during shutdown. If you’d like, I’m here to help you with implementing this or if you have any other questions! Sources: egress/recording_agent.py | examples/api.py | tests/test_ipc.py
t
Copy code
room:
    # 참가자 연결 끊김 유예 시간 (기본값은 20초)
    # 10초로 변경하는 예시
    disconnect_delay: 10  
    # 방이 비었을 때 대기 시간 (기본값은 300초/5분)
    # 60초로 변경하는 예시
    empty_timeout: 60
@limited-planet-15554 livekit.yaml 파일에 해당 부분 수정하면 될 것으로 보여집니다.
t
Thank you for your question! I want to clarify that modifying
disconnect_delay
in
livekit.yaml
won’t impact the egress recording duration because this setting isn’t part of LiveKit’s configuration. Instead, the valid room timeout settings you can use are
empty_timeout
and
departure_timeout
. These control how the room behaves over time but don’t directly affect the recording duration. If you want the recording to stop right after the call ends, here are a couple of friendly options: • Delete the room as soon as the human participant leaves, which will automatically stop the egress recording. • Use the
StopEgress
API to manually stop the recording whenever you choose. If you’d like, I’m here to help you with these configurations or guide you through the best approach. Just let me know! Sources: test/publish.go | pkg/config/config.go | livekit-rtc/livekit/rtc/room.py