m
hi
t
Thanks for reaching out, Rahib. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi — how can I help you today? What are you trying to do with LiveKit (setup, SDKs, rooms, permissions, billing, or something else)?
m
How do i record my phone call and save it on machine where egress is running?
t
You're asking how to record a phone (SIP) call and save the recording on the machine where LiveKit egress runs — here’s how to do that. 1. Use SIP with Auto Egress • Configure your SIP dispatch rule to enable Auto Egress so incoming SIP calls create a room and start egress automatically. • In that rule set
room_config.egress
to record the call. 1. Save files locally on the egress machine • Specify a local absolute path for the egress output and do NOT include any cloud storage fields (no
s3
,
gcp
,
azure
, etc.). The file will be written to the filesystem of the machine/container running the egress service. • Ensure the directory exists and is writable by the egress process:
Copy code
mkdir -p /path/to/recordings && chmod 755 /path/to/recordings
1. Example outputs • Record as a single MP4 file (room egress):
Copy code
{
  "room": {
    "file": {
      "filepath": "/path/to/recordings/call-output.mp4"
    }
  }
}
• Use segmented HLS:
Copy code
{
  "room": {
    "segments": {
      "filename_prefix": "/path/to/recordings/call-segment"
    }
  }
}
• For raw audio track egress (no transcoding), use Track Egress with
file
output (e.g.,
.ogg
for Opus):
Copy code
{
  "room_name": "call-room-123",
  "track_id": "TR_AUDIO_TRACK_ID",
  "file": {
    "filepath": "/path/to/recordings/raw-audio.ogg"
  }
}
1. Verify egress deployment • Confirm the egress service is running where you expect (the filesystem you point to is the egress host/container). • Confirm permissions so egress can write to the chosen path. If you want, tell me: • Do you prefer a single MP4, raw audio (
.ogg
), or HLS segments? • Are you using Auto Egress or starting egress manually? I can then give the exact JSON for your SIP dispatch rule or a StartEgress/StartTrackEgress request. Sources: Auto egress | LiveKit docs | Universal Egress | Recording and export | LiveKit docs | Egress output types | LiveKit docs
m
does this work with self hosted ?
t
Yes — this works with self-hosted LiveKit. • The egress process writes files to the filesystem where it runs, so when you self-host egress (container or VM) recordings saved to a local
filepath
or
filename_prefix
will land on that host. • Make sure the egress service is deployed on the machine where you want files stored and that the target directory exists and is writable by the egress process:
Copy code
mkdir -p /path/to/recordings && chmod 755 /path/to/recordings
• Omit any cloud storage fields (
s3
,
gcp
,
azure
, etc.) in the egress output config to keep files local. If you’d like, tell me which output type you want (single MP4, raw audio
.ogg
, or HLS segments) and whether you use Auto Egress for SIP or will start egress manually — I’ll provide the exact JSON/config for your self-hosted setup.
m
I want .mp4 and can you tell me step by step on how to set it ?
t
You're asking for a step-by-step guide to record a SIP phone call with LiveKit self-hosted egress and save it as an MP4 on the egress machine. Follow these steps. 1) Ensure egress service is deployed • Run the LiveKit egress service on the host (container or VM) where you want recordings stored. • Confirm the egress process is running and reachable from your LiveKit/SIP setup. 2) Prepare a local directory and permissions on the egress host • Create the folder and allow egress to write:
Copy code
mkdir -p /var/lib/livekit/recordings
chmod 755 /var/lib/livekit/recordings
chown <egress-user>:<egress-user> /var/lib/livekit/recordings
Replace
<egress-user>
with the user the egress process runs as (or skip chown if running as root/container user). 3) Configure your SIP dispatch rule to enable Auto Egress (automatic recording) • In your SIP dispatch rule, set
room_config.egress
to produce a room egress with a file output pointing to an absolute local path. Example JSON snippet for MP4 output:
Copy code
{
  "room_config": {
    "egress": {
      "room": {
        "file": {
          "filepath": "/var/lib/livekit/recordings/call-{{CALL_ID}}.mp4"
        }
      }
    }
  }
}
• Use a template or unique filename per call (e.g., include timestamp or call id) so files don’t overwrite. 4) (Alternative) Start egress manually after SIP bridge creates the room • If you prefer starting egress programmatically, call StartRoomEgress or StartTrackEgress against the egress API after the SIP call creates the room. • Example StartRoomEgress payload to create an MP4 file:
Copy code
{
  "room_name": "call-room-123",
  "file": {
    "filepath": "/var/lib/livekit/recordings/call-room-123.mp4"
  }
}
5) File format and track considerations • Room file egress will produce an MP4 (audio + any video if present). For SIP audio-only calls, the MP4 will contain the audio track. • If you want raw audio instead, use Track Egress with `.ogg`; but you requested MP4 so use room/file or combine tracks into MP4. 6) Verify and test • Place a test SIP call through your configured dispatch rule. • On the egress host, watch for the MP4 file in
/var/lib/livekit/recordings/
. • Check file ownership and size; confirm audio plays. 7) Troubleshooting tips • If no file appears: ◦ Confirm the egress service logs show StartEgress succeeded. ◦ Confirm the path in the egress config is absolute and writable by egress. • If permission errors appear, adjust directory ownership/permissions or run egress under a user with write access. If you’d like, tell me: • the exact path you want to use for recordings, and • whether you want Auto Egress (SIP dispatch rule) or to start egress manually. I’ll return the precise JSON for your SIP dispatch rule or StartRoomEgress request with that filename pattern.
m
ok so i already have a dispatch rule created how do i update it to include room config as well ? Can you give me lk command?
t
You're updating your existing SIP dispatch rule to add room egress that writes MP4 files locally. Below are the exact steps and an
lk
CLI example. 1) Export your current dispatch rule to a file (so you can edit safely)
Copy code
lk sip dispatch get --id <DISPATCH_RULE_ID> > dispatch-rule.json
2) Edit
dispatch-rule.json
and add a
room_config.egress
block. Example (MP4 written to local path):
Copy code
{
  "room_config": {
    "egress": {
      "room": {
        "file": {
          "filepath": "/var/lib/livekit/recordings/call-{{call_id}}-{{time}}.mp4"
        }
      }
    }
  }
}
• Use an absolute
filepath
on the egress host. • Keep out any
s3
,
gcp
, or
azure
sections to store locally. 3) Update the dispatch rule with the edited file
Copy code
lk sip dispatch update --id <DISPATCH_RULE_ID> dispatch-rule.json
4) Confirm • Place a test SIP call routed by that dispatch rule. • Check
/var/lib/livekit/recordings/
on the egress host for the MP4. If you want, tell me your dispatch rule ID and the exact local path you prefer and I’ll generate a ready-to-use
dispatch-rule.json
snippet with that filename pattern. Sources: Egress examples | LiveKit docs | SIP dispatch rule | LiveKit docs | SIP overview | LiveKit docs
m
will this only add room config or do i need other settings in there as well ? Or will this command make them empty?
t
You're asking whether
lk sip dispatch update
will only add the
room_config
or overwrite other fields. It will only update the fields you include — it will not clear or remove existing fields. What to do: 1. Export current rule (safe backup):
Copy code
lk sip dispatch get --id <DISPATCH_RULE_ID> > dispatch-rule.json
1. Add a
room_config.egress
block to that file (example MP4):
Copy code
{
  "room_config": {
    "egress": {
      "room": {
        "file": {
          "filepath": "/var/lib/livekit/recordings/call-{{call_id}}-{{time}}.mp4"
        }
      }
    }
  }
}
1. Update the rule:
Copy code
lk sip dispatch update --id <DISPATCH_RULE_ID> dispatch-rule.json
Notes: • Fields not present in
dispatch-rule.json
are preserved. • Backing up with
get
ensures you can restore or edit the full rule if you prefer. • Tell me your dispatch rule ID and preferred filepath if you want a ready-to-use JSON. Sources: SIP APIs | LiveKit docs