From ebc11691e2e467349bc1ecbd2efffdcdb7a17b6b Mon Sep 17 00:00:00 2001 From: isaacclad Date: Sat, 4 Jul 2026 03:42:28 +0000 Subject: [PATCH] Fix LiveKit egress preset call and attach completion webhook per job. Pass null encoding preset to match the PHP SDK, and register the meet webhook on each egress start so LiveKit Cloud does not need a global webhook URL. Co-authored-by: Cursor --- .env.example | 1 + .../Meet/Media/LiveKitEgressService.php | 23 +++++++++++++++---- config/meet.php | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index e3979d1..d46401d 100644 --- a/.env.example +++ b/.env.example @@ -49,6 +49,7 @@ MEET_RECORDINGS_DISK=local MEET_RECORDING_MAX_MB=512 # Server-side recording via LiveKit Egress (recommended for production) MEET_EGRESS_ENABLED=false +MEET_EGRESS_WEBHOOK_URL= MEET_EGRESS_S3_BUCKET= MEET_EGRESS_S3_REGION= MEET_EGRESS_S3_ACCESS_KEY= diff --git a/app/Services/Meet/Media/LiveKitEgressService.php b/app/Services/Meet/Media/LiveKitEgressService.php index 35ef016..2c9ac03 100644 --- a/app/Services/Meet/Media/LiveKitEgressService.php +++ b/app/Services/Meet/Media/LiveKitEgressService.php @@ -8,9 +8,9 @@ use App\Models\Session; use Illuminate\Support\Facades\Log; use Livekit\EncodedFileOutput; use Livekit\EncodedFileType; -use Livekit\EncodingOptionsPreset; use Livekit\EgressInfo; use Livekit\S3Upload; +use Livekit\WebhookConfig; use RuntimeException; class LiveKitEgressService @@ -41,14 +41,16 @@ class LiveKitEgressService $client = $this->client(); $layout = $this->egressLayout($recording->layout); $output = $this->buildFileOutput($session, $recording); - $preset = EncodingOptionsPreset::H264_720P_30; - return $client->startRoomCompositeEgress( $session->media_room_name, $layout, $output, - $preset, + null, $audioOnly, + false, + '', + \Livekit\AudioMixing::DEFAULT_MIXING, + $this->egressWebhooks(), ); } @@ -122,6 +124,19 @@ class LiveKitEgressService }; } + /** + * @return list + */ + protected function egressWebhooks(): array + { + $url = (string) config('meet.recordings.egress.webhook_url', ''); + if ($url === '') { + $url = rtrim((string) config('app.url'), '/').'/api/livekit/webhook'; + } + + return [new WebhookConfig(['url' => $url])]; + } + public function tryStart(Session $session, Recording $recording): ?array { if (! $this->isAvailable()) { diff --git a/config/meet.php b/config/meet.php index 944609e..4488f86 100644 --- a/config/meet.php +++ b/config/meet.php @@ -116,6 +116,7 @@ return [ 'processing_timeout_minutes' => (int) env('MEET_RECORDING_PROCESSING_TIMEOUT_MINUTES', 15), 'egress' => [ 'enabled' => (bool) env('MEET_EGRESS_ENABLED', false), + 'webhook_url' => env('MEET_EGRESS_WEBHOOK_URL', ''), 's3' => [ 'access_key' => env('MEET_EGRESS_S3_ACCESS_KEY', env('AWS_ACCESS_KEY_ID')), 'secret' => env('MEET_EGRESS_S3_SECRET', env('AWS_SECRET_ACCESS_KEY')),