{"record":{"id":"a61c6fb8b258ac6a","repo":"remotion-dev/remotion","slug":"expected-duration-in-m3u-playlist","errorCode":null,"errorMessage":"Expected duration in m3u playlist","messagePattern":"Expected duration in m3u playlist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/m3u/get-playlist.ts","lineNumber":59,"sourceCode":"\nexport const getPlaylist = (\n\tstructure: M3uStructure,\n\tsrc: string,\n): M3uPlaylist => {\n\tconst allPlaylists = getAllPlaylists({structure, src});\n\n\tconst playlists = allPlaylists.find((box) => box.src === src);\n\tif (!playlists) {\n\t\tthrow new Error(`Expected m3u-playlist with src ${src}`);\n\t}\n\n\treturn playlists as M3uPlaylist;\n};\n\nexport const getDurationFromPlaylist = (playlist: M3uPlaylist): number => {\n\tconst duration = playlist.boxes.filter((box) => box.type === 'm3u-extinf');\n\tif (duration.length === 0) {\n\t\tthrow new Error('Expected duration in m3u playlist');\n\t}\n\n\treturn duration.reduce((acc, d) => acc + d.value, 0);\n};\n","sourceCodeStart":41,"sourceCodeEnd":64,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/m3u/get-playlist.ts#L41-L64","documentation":"Thrown by getDurationFromPlaylist() at get-playlist.ts:59. It filters the playlist's boxes for m3u-extinf entries (from #EXTINF directives) and sums their durations. If the filter returns an empty array — meaning the playlist contains zero #EXTINF lines — it throws, because the parser cannot determine total duration from a playlist with no segments.","triggerScenarios":"A media playlist that contains only header directives (#EXTM3U, #EXT-X-TARGETDURATION, #EXT-X-ENDLIST) but no #EXTINF segment entries; a live playlist fetched before any segments were published; a zero-length VOD playlist.","commonSituations":"Live HLS streams polled too early before the origin server has published segments; empty playlist returned by a misconfigured origin or stale CDN cache; a playlist intentionally containing only an #EXT-X-ENDLIST marker.","solutions":["Ensure the media playlist contains at least one #EXTINF directive with a segment URI","For live streams, wait until segments are published before attempting to parse","Manually inspect the fetched playlist text to confirm segments exist"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-fetch the media playlist and check for EXTINF lines\nconst text = await (await fetch(playlistUrl)).text();\nif (!text.includes('#EXTINF')) {\n  throw new Error('Playlist has no segments — not ready for parsing');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({src: playlistUrl});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Expected duration in m3u playlist') {\n    // playlist has no segments — for live streams, retry after a delay\n  }\n  throw e;\n}","preventionTips":["For live HLS streams, wait until segments are published before parsing","Check playlist content manually if the stream origin may serve empty playlists"],"tags":["hls","m3u8","duration","empty-playlist","extinf"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}