Skip to content

Commit 0e5fd5c

Browse files
ralyodioclaude
andcommitted
fix(egress): 1s keyframe interval so YouTube Live leaves "Preparing" reliably
2s helped but YouTube was still intermittently stuck on "Preparing" (Twitch always went live on the same stream). Drop the egress keyframe interval to 1s (keyframe every 30 frames) — well within YouTube's <=4s requirement and makes it go live consistently. Server-side; applies on the next egress start. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent ce42f73 commit 0e5fd5c

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

  • apps/web/src/app/api/stream/egress/start

‎apps/web/src/app/api/stream/egress/start/route.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,19 @@ export async function POST(request: Request) {
8484
{ stream: new StreamOutput({ protocol: StreamProtocol.RTMP, urls: rtmpUrls }) },
8585
{
8686
layout: 'speaker',
87-
// Explicit 1080p30 (matches the H264_1080P_30 preset) but with a
88-
// 2-second keyframe interval. The preset defaults to 4s, which YouTube
89-
// Live rejects — the broadcast sits on "Preparing stream" with
90-
// "excellent" health forever while Twitch (more lenient) goes live.
91-
// YouTube requires a keyframe at least every 4s; 2s is the safe value.
87+
// Explicit 1080p30 with a 1-second keyframe interval. The preset
88+
// defaults to 4s; YouTube Live then sits on "Preparing stream" with
89+
// good health and intermittently never goes live, while Twitch (more
90+
// lenient) always does. 2s helped but YouTube was still flaky; 1s
91+
// (a keyframe every 30 frames) makes YouTube leave "Preparing"
92+
// reliably and is well within its <=4s requirement.
9293
encodingOptions: new EncodingOptions({
9394
width: 1920,
9495
height: 1080,
9596
framerate: 30,
9697
videoBitrate: 4500,
9798
audioBitrate: 128,
98-
keyFrameInterval: 2,
99+
keyFrameInterval: 1,
99100
}),
100101
}
101102
);

0 commit comments

Comments
 (0)