diff --git a/server/src/cameras.ts b/server/src/cameras.ts index e81a1be..ca7aea2 100644 --- a/server/src/cameras.ts +++ b/server/src/cameras.ts @@ -132,7 +132,10 @@ export function go2rtcSources(c: CameraRecord, ffmpegAvailable: boolean, eufySou for (const e of c.caps.extra ?? []) main.push(e); if (ffmpegAvailable) { if (c.kind === "http") main.push(`ffmpeg:${c.streamKey}#video=h264`); - else main.push(`ffmpeg:${c.streamKey}#audio=aac`, `ffmpeg:${c.streamKey}#video=mjpeg`); + // Opus lets WebRTC carry the camera audio. Without it the player's WebRTC stream has video only and + // video-rtc.js drops it in favour of MSE (H.264+AAC scores higher), so live view never gets WebRTC latency. + // go2rtc only starts these transcoders when a consumer asks for that codec. + else main.push(`ffmpeg:${c.streamKey}#audio=aac`, `ffmpeg:${c.streamKey}#audio=opus`, `ffmpeg:${c.streamKey}#video=mjpeg`); } out.push({ name: c.streamKey, sources: main }); if (c.subUrl) out.push({ name: `${c.streamKey}_sub`, sources: [c.subUrl] }); diff --git a/server/test/brands.test.ts b/server/test/brands.test.ts index 8770f70..8820bd7 100644 --- a/server/test/brands.test.ts +++ b/server/test/brands.test.ts @@ -88,7 +88,7 @@ describe("go2rtc sources", () => { test("main + sub with ffmpeg helpers", () => { const s = go2rtcSources(base, true); expect(s[0]!.name).toBe("c1"); - expect(s[0]!.sources).toEqual(["rtsp://a/1", "ffmpeg:c1#audio=aac", "ffmpeg:c1#video=mjpeg"]); + expect(s[0]!.sources).toEqual(["rtsp://a/1", "ffmpeg:c1#audio=aac", "ffmpeg:c1#audio=opus", "ffmpeg:c1#video=mjpeg"]); expect(s[1]).toEqual({ name: "c1_sub", sources: ["rtsp://a/2"] }); }); test("push camera has no source", () => {