Livekit ergess How to detect when all s3 upload is...
# ask-ai
c
Livekit ergess How to detect when all s3 upload is done
t
Thanks for reaching out, Cao. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To keep an eye on when all your S3 uploads are wrapped up in LiveKit, you’ve got a couple of friendly options: webhooks or the Egress API. • Webhooks: Just listen out for the
egress_ended
webhook event—that’s your signal that the egress process has finished (or if something went wrong). This is the most dependable way to know all your uploads are good to go. • EgressInfo API Polling: You can also use the
ListEgress
or
StopEgress
API to grab the
EgressInfo
object. Then, check the
status
field—when it reads
EGRESS_COMPLETE
(for files) or
FINISHED
(for stream segments), you’re all set and uploads are complete. Oh, and one more thing—LiveKit wraps up all uploads by creating a manifest file, which gets uploaded last after all your media files have made it safely to S3. Sources: Quotas and limits | LiveKit Docs | lib/livekit/proto/livekit_egress_pb.rb | pkg/pipeline/sink/image.go
c
So i should not disableManifest=true
t
Hey there! Just a quick heads-up: setting
disableManifest=true
in your LiveKit egress configurations means the system won’t upload a JSON manifest file that holds metadata about your output. Here’s how that plays out for different output types: • For EncodedFileOutput, DirectFileOutput, and AutoTrackEgress, the manifest file (like
{filepath}.json
) simply won’t be created or uploaded. • For ImageOutput, the manifest file that lists exported snapshot filenames won’t be created or uploaded either. • For SegmentedFileOutput (think HLS), the manifest file (the m3u8 playlist) won’t be uploaded. By default,
disableManifest
is set to
false
. So, if you depend on that manifest file to make sure all your uploads are wrapped up, it’s best to keep
disableManifest=true
off. Sources: Egress API | LiveKit Docs | auth/accesstoken_test.go
c
example for livekit egress webhook
t
Here's a friendly example to help you configure and handle LiveKit egress webhooks: Webhook Configuration You’ve got two ways to set up webhooks: • Server-level Configuration: Just add this to your LiveKit server config:
Copy code
webhook:
  api_key: 'api-key-to-sign-with'
  urls:
    - <YOUR_WEBHOOK_URL>
• Per-Request Webhooks: You can also specify extra webhooks right in your egress request using the
webhooks
field. Example Webhook Payload When an egress finishes, you’ll get a payload like this:
Copy code
{
  "event": "egress_ended",
  "room": {
    "sid": "RM_abc123",
    "name": "my-room"
  },
  "egressInfo": {
    "egressId": "EG_xyz789",
    "roomId": "RM_abc123",
    "roomName": "my-room",
    "status": "EGRESS_COMPLETE",
    "startedAt": 1640995200000,
    "endedAt": 1640995800000,
    "fileResults": [
      {
        "filename": "my-room-20220101T120000.mp4",
        "location": "s3://my-bucket/recordings/my-room-20220101T120000.mp4",
        "size": 52428800,
        "duration": 600000
      }
    ]
  }
}
Webhook Handler Example Here’s a simple Node.js example to help you handle those webhooks:
Copy code
const lksdk = require('livekit-server-sdk');
const http = require('http');

const receiver = new lksdk.WebhookReceiver(
  process.env.LIVEKIT_API_KEY, 
  process.env.LIVEKIT_API_SECRET
);

const webhookHandler = (req, res) => {
  let data = '';
  req.on('data', chunk => {
    data += chunk;
  });

  req.on('end', () => {
    const event = receiver.receive(data, req.headers.authorization);
    
    console.log('received webhook event', event);
    
    // Handle different egress events
    switch(event.event) {
      case 'egress_started':
        console.log('Egress started:', event.egressInfo);
        break;
      case 'egress_updated':
        console.log('Egress updated:', event.egressInfo);
        break;
      case 'egress_ended':
        console.log('Egress ended:', event.egressInfo);
        break;
    }
    
    res.writeHead(200);
    res.end();
  });
}

const server = http.createServer(webhookHandler);
server.listen(3000, () => {
  console.log('Webhook server running on port 3000');
});
If you have any questions or want a hand with setting up or handling your webhooks, just let me know—I’m here to help! Sources: livekit-protocol/livekit/protocol/egress.py | examples/webhooks-http/README.md | Egress & Storage | livekit/livekit_composite | DeepWiki | Webhooks | LiveKit Docs