where to enable egress for recording
# ask-ai
e
where to enable egress for recording
t
Thanks for reaching out, Aman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Do you mean automatic egress when a room is created (auto‑recording) or on‑demand egress for an existing room/participant? • If you mean auto‑egress: enable it in the room configuration when calling CreateRoom by setting the
egress
field (room_config.egress). • If you mean on‑demand recording: use the Egress API (Room Composite, Participant, Track Composite, or Track egress) via Server SDKs, the LiveKit CLI, or direct calls to the
/twirp/livekit.Egress/
endpoints. If you tell me which method you want (auto vs on‑demand), which SDK or tool you’re using (Go/JS/Python/CLI/curl), and whether you’re recording to S3/HLS/file, I’ll give the exact config or example request. Sources: Auto egress | LiveKit docs | Recording and export | LiveKit docs | Egress API | LiveKit docs | How to enable auto-egress with SIP
e
is livekit required for egress?
livekit cloud
t
Yes — LiveKit is required for egress. Egress is a LiveKit feature that accesses LiveKit room streams (or web pages for web egress) and runs via LiveKit’s egress service. For LiveKit Cloud: • Egress is provided as part of the LiveKit service; you must use your LiveKit Cloud URL, API key, and API secret to start egress. • Ensure your token has the
roomRecord
permission when starting recordings. • You can enable auto‑egress in
CreateRoom
by setting the
egress
field, or start on‑demand egress via the Egress API (Room Composite, Participant, Track, or Web egress) using Server SDKs, CLI, or direct API calls. Tell me whether you want auto‑egress or on‑demand, which SDK/tool you’ll use (Cloud console/Go/JS/Python/CLI/curl), and your target output (S3/HLS/file) and I’ll provide the exact config or request example.
e
how can i achieve recording with self host livekit server
t
You're running a self‑hosted LiveKit server and want to enable recording—got it. A few quick questions so I give the exact steps you need: 1. Do you want automatic recording when rooms are created (auto‑egress) or on‑demand recording for existing rooms/participants? 2. Which SDK or tool will you use to start egress? (Go / JavaScript / Python / CLI / curl / direct API) 3. Where do you want recordings stored or streamed? (S3, local filesystem, HLS, RTMP, etc.) 4. Are you running a single LiveKit server or a distributed setup with Redis? Do you already have the egress service deployed or do you need instructions to deploy it? Answer these and I’ll provide step‑by‑step config, commands, and an example request for your setup.
e
i need automatic recording i'm using python recording should store on aws s3 currently running single livekit server
t
Good — you want automatic recording on a self‑hosted LiveKit server using Python with outputs to AWS S3. Below are the exact steps you need to deploy and configure. 1) Deploy the Egress service (required) • Egress is a separate service and must run alongside your LiveKit server. • Example Docker run (replace placeholders):
Copy code
docker run -d \
  --cap-add=SYS_ADMIN \
  -e EGRESS_CONFIG_BODY='{
    "api_key":"YOUR_LIVEKIT_API_KEY",
    "api_secret":"YOUR_LIVEKIT_API_SECRET",
    "ws_url":"ws://YOUR_LIVEKIT_HOST:7880",
    "redis": {"address":"YOUR_REDIS_HOST:6379"}
  }' \
  livekit/egress
• Notes:
--cap-add=SYS_ADMIN
is needed for Chrome sandboxing. Egress must connect to the same Redis instance as LiveKit. Minimum recommended resources: ~4 CPU / 4 GB RAM. 2) Ensure permissions & AWS setup • LiveKit API key must have
roomRecord
permission. • Create an S3 bucket and IAM credentials with PutObject/List permissions. • Set environment vars on the machine running your Python code (or Egress if using S3 from egress):
Copy code
LIVEKIT_API_KEY=...
LIVEKIT_API_SECRET=...
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_REGION=...
AWS_BUCKET_NAME=...
3) Install Python SDK
Copy code
pip install livekit-api
4) Start automatic recording (recommended flow) • The Python SDK does not implicitly auto‑start egress on CreateRoom in some setups, so trigger egress immediately after room creation (or when the first participant joins). • Example: create room then start Room Composite egress to S3. Synchronous-style example (async shown where required):
Copy code
import asyncio
import os
from livekit import api

async def start_room_recording(room_name: str):
    lk = api.LiveKitAPI(
        url="http://YOUR_LIVEKIT_HOST:7880",
        api_key=os.getenv("LIVEKIT_API_KEY"),
        api_secret=os.getenv("LIVEKIT_API_SECRET"),
    )

    req = api.RoomCompositeEgressRequest(
        room_name=room_name,
        file_outputs=[
            api.EncodedFileOutput(
                filepath=f"recordings/{room_name}-{int(__import__('time').time())}.mp4",
                file_type=api.EncodedFileType.MP4,
                s3=api.S3Upload(
                    bucket=os.getenv("AWS_BUCKET_NAME"),
                    region=os.getenv("AWS_REGION"),
                    access_key=os.getenv("AWS_ACCESS_KEY_ID"),
                    secret=os.getenv("AWS_SECRET_ACCESS_KEY"),
                ),
            )
        ],
        layout="grid"
    )

    egress_info = await lk.egress.start_room_composite_egress(req)
    print("Started egress:", egress_info.egress_id)
    await lk.aclose()

# Usage: call this after creating the room or when first participant joins
if __name__ == "__main__":
    asyncio.run(start_room_recording("my-auto-room"))
5) Automate triggering • Trigger the recording script after room creation: ◦ Call it from the same service that creates rooms, or ◦ Run a background worker that starts recording when a room appears or when first participant joins. • You can also periodically call
ListEgress
to monitor status and
StopEgress
to stop. 6) Verify & troubleshoot • Verify Egress service logs and that it connects to Redis and LiveKit. • Check
ListEgress
to view status. • If Chrome fails to start in egress: ensure
--cap-add=SYS_ADMIN
. • If S3 upload fails: check AWS creds, region, bucket policy, and that Egress or your Python process can reach S3. If you want, I can: • Provide a Docker Compose example including LiveKit + Egress + Redis + example worker, or • Give a ready-to-run Python webhook/worker that creates the room and immediately starts recording. Which would you prefer? Sources: Recording and export | LiveKit docs | Auto egress | LiveKit docs | Egress output types | LiveKit docs | RoomComposite Egress | LiveKit Docs | Self-hosting the Egress Service | LiveKit docs
e
will it also work for phone calls
t
Yes — you can record phone (SIP) calls with the same egress setup. • For SIP calls, configure SIP dispatch rules to create or route a room when the call connects and enable egress in that rule (auto‑egress via
room_config.egress
). • With a self‑hosted setup, ensure the Egress service is deployed and connected to the same Redis/LiveKit instance so it can record the SIP-backed room. • Recordings can be output to S3 the same way (Room Composite, Track, or Participant egress) using your Python code or by auto‑starting egress from the SIP dispatch rule. If you want, tell me how your SIP is currently configured (do you create a LiveKit room from the SIP dispatch, or do calls join an existing room?), and I’ll give the exact SIP dispatch example and Python/S3 config.
e
share example of SIP dispatch rule
t
Below is a concise example SIP dispatch rule that enables auto‑egress (automatic recording) to AWS S3 for inbound phone calls on a self‑hosted LiveKit setup. This is the JSON you can use with the LiveKit API/CLI or translate into the Python SDK fields in your existing config. Example JSON dispatch rule (auto‑record to S3):
Copy code
{
  "name": "Record-Inbound-SIP-Calls",
  "trunk_ids": [
    "YOUR_INBOUND_TRUNK_ID"
  ],
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  },
  "roomConfig": {
    "egress": {
      "room": {
        "layout": "grid",
        "fileOutputs": [
          {
            "filepath": "sip-recordings/{room_name}-{time}.mp4",
            "s3": {
              "bucket": "your-s3-bucket",
              "region": "us-west-2",
              "accessKey": "AWS_ACCESS_KEY_ID",
              "secret": "AWS_SECRET_ACCESS_KEY"
            }
          }
        ]
      }
    }
  }
}
Notes and quick requirements: • Replace placeholders:
YOUR_INBOUND_TRUNK_ID
, S3 bucket, region, and AWS keys (use secure secrets in production). • Egress service must be deployed and connected to the same Redis/LiveKit instance. • API key used must have
roomRecord
permission. •
roomPrefix
creates one room per call (e.g., call-abc123). The egress
room
block uses Room Composite egress to produce an MP4. • You can instead use
tracks
or
participant
egress inside
roomConfig.egress
if you prefer per-track or per-participant files. How to apply: • CLI: save as dispatch-rule.json and run
lk sip dispatch create dispatch-rule.json
(or use the equivalent API call). • Python SDK: populate
CreateSIPDispatchRuleRequest
with
room_config.egress
fields matching the JSON above. If you want, I can: • Convert this exact JSON into a ready-to-run Python SDK example that creates the trunk and dispatch rule and ensures S3 credentials are read from env vars. Which would you prefer? Sources: sip | livekit/livekit_composite | DeepWiki | SIP overview | LiveKit docs | examples/bank-ivr | livekit/livekit_composite | DeepWiki | Egress examples | LiveKit docs | Egress API | LiveKit docs
e
what's the cost of livekit egress that comes with livekit cloud?
t
LiveKit Cloud egress is metered and depends on plan and usage. Key points: • Transcode minutes (Room Composite, Participant, Track Composite): ◦ Build (Free): 60 minutes included ◦ Ship ($50/mo): 600 minutes included ◦ Scale ($500/mo): 8,000 minutes included ◦ Overage rates (approx): video ~$0.02–$0.015/min, audio ~$0.005–$0.004/min • Track Egress (raw single-track exports): ◦ Same included minutes per plan (60 / 600 / 8,000) ◦ Overage: ~$0.001/min • Concurrent exports: ◦ Build: 2 concurrent ◦ Ship: 100 concurrent ◦ Scale/Enterprise: unlimited Unused included minutes do not roll over. For exact current pricing, pick a plan or share your expected monthly minutes and I’ll estimate monthly cost. Sources: LiveKit Pricing | Quotas and limits | LiveKit docs
e
if i 've build , i will get 60 minutes free and after that $0.001/min
t
You're almost right — a small correction: • Build plan includes 60 free minutes per month. • After that, the overage rate depends on egress type: ◦ Track egress (raw single-track exports): $0.001 per minute. ◦ Transcode egress (Room Composite / Participant / Track Composite): ▪︎ Video: ~$0.02 per minute (Build overage) ▪︎ Audio-only: ~$0.005 per minute If you want, tell me your expected monthly minutes and whether recordings are video or audio-only and I’ll estimate monthly cost.
e
my recording will be only for phone calls
t
Since your recordings are phone calls (audio-only): • Build plan: 60 free minutes/month. • After 60 minutes: audio-only transcode egress overage is $0.005 per minute. • If you only need raw track exports ( Track Egress ), overage is $0.001 per minute — but Track Egress exports single raw tracks (not a transcoded MP4 composite). Tell me whether you want: • a single audio composite file per call (Room Composite / transcode), or • raw per-participant audio tracks (Track Egress) — and I’ll estimate monthly cost for your expected minutes.
e
and can i do following: Livekit egress of livekit cloud with my self hosted livekit server
t
You cannot use LiveKit Cloud’s managed egress with a self‑hosted LiveKit server. What you can do: • Self‑host the LiveKit Egress service alongside your LiveKit server. ◦ Deploy egress (Docker/Helm/VM), point it at the same LiveKit URL and Redis instance, and provide S3 credentials. ◦ Egress then handles auto‑recording (via room_config.egress / dispatch rules) and uploads to S3. • Keep using LiveKit Cloud (managed) including its egress — but that requires using LiveKit Cloud’s hosted LiveKit servers (not your self‑hosted instance). If you want, I can send: • A minimal Docker Compose example (LiveKit + Redis + Egress) configured for S3, or • Exact egress Docker env/config and the Python snippet to auto‑start recordings for SIP calls. Which do you prefer? Sources: LiveKit Cloud | LiveKit Docs | Recording and export | LiveKit docs | Self-hosting the Egress Service | LiveKit docs