From 43ed99cf0a3b6efdacaafd0799c9e4f411ed63ea Mon Sep 17 00:00:00 2001 From: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri, 4 Dec 2026 13:44:44 +0000 Subject: [PATCH 1/2] fix(media-server): import Loom HLS audio when the video playlist is empty --- .../loom-importer/import.integration.test.ts | 27 ++++++++++++++++++- .../src/loom-importer/streaming.ts | 10 ++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/apps/media-server/src/__tests__/loom-importer/import.integration.test.ts b/apps/media-server/src/__tests__/loom-importer/import.integration.test.ts index 250a96bb39d..5f3bf718d78 100644 --- a/apps/media-server/src/__tests__/loom-importer/import.integration.test.ts +++ b/apps/media-server/src/__tests__/loom-importer/import.integration.test.ts @@ -296,6 +296,8 @@ describe("runLoomImport", () => { ); await cp(audioOnly, join(root, "hls-audio-gap"), { recursive: true }); await rm(join(root, "hls-audio-gap", "audio-001.ts")); + await cp(audioOnly, join(root, "hls-empty-video"), { recursive: true }); + await writeFile(join(root, "hls-empty-video", "video.m3u8"), emptyPlaylist); ffmpeg( [ "-f", @@ -656,7 +658,30 @@ describe("runLoomImport", () => { ).toBe(false); }, 60_000); - test("still fails when the video rendition has no segments", async () => { + test("imports the audio when the video rendition has no segments", async () => { + const job = await run( + request( + "hls-empty-video", + `${base}/media/hls-empty-video/master.m3u8?${SIGNATURE}`, + ), + ); + expect(job?.phase).toBe("complete"); + expect(job?.metadata).toMatchObject({ + width: 1280, + height: 720, + videoCodec: "h264", + audioCodec: "aac", + }); + expect(job?.metadata?.duration).toBeCloseTo(7, 0); + expect( + sourceRequests.some( + (path) => + path.startsWith("/media/hls-empty-video/") && path.includes("video-"), + ), + ).toBe(false); + }, 60_000); + + test("still fails when no rendition has segments", async () => { const job = await run( request("hls-empty", `${base}/media/hls-empty/master.m3u8?${SIGNATURE}`), ); diff --git a/apps/media-server/src/loom-importer/streaming.ts b/apps/media-server/src/loom-importer/streaming.ts index 329d26259e9..29f6775d2e5 100644 --- a/apps/media-server/src/loom-importer/streaming.ts +++ b/apps/media-server/src/loom-importer/streaming.ts @@ -277,8 +277,7 @@ export async function prefetchMaterializedHls( try { resources = listMediaPlaylistResources(content); } catch (error) { - if (track.name === "audio" && error instanceof EmptyHlsPlaylistError) - return null; + if (error instanceof EmptyHlsPlaylistError) return null; throw error; } const lines = content.split(/\r?\n/); @@ -293,7 +292,12 @@ export async function prefetchMaterializedHls( }), ); const playlists = loaded.filter((playlist) => playlist !== null); - if (playlists.length < loaded.length) + if (playlists.length === 0) + throw new EmptyHlsPlaylistError("HLS playlist has no media segments"); + if ( + playlists.length < loaded.length && + playlists.some((playlist) => playlist.name === "video") + ) selection = withoutAudioRendition(selection); const downloads = playlists.flatMap((playlist) => playlist.resources.map((resource, index) => ({ From 8154dca9400a02606db45f8b41f80d1b78065ff4 Mon Sep 17 00:00:00 2001 From: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri, 4 Dec 2026 13:49:12 +0000 Subject: [PATCH 2/2] test(media-server): drop the timeout override on the empty video playlist test --- .../src/__tests__/loom-importer/import.integration.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/media-server/src/__tests__/loom-importer/import.integration.test.ts b/apps/media-server/src/__tests__/loom-importer/import.integration.test.ts index 5f3bf718d78..156d8f80dab 100644 --- a/apps/media-server/src/__tests__/loom-importer/import.integration.test.ts +++ b/apps/media-server/src/__tests__/loom-importer/import.integration.test.ts @@ -679,7 +679,7 @@ describe("runLoomImport", () => { path.startsWith("/media/hls-empty-video/") && path.includes("video-"), ), ).toBe(false); - }, 60_000); + }); test("still fails when no rendition has segments", async () => { const job = await run(