remotion-dev/remotion · error · Error
Expected duration in m3u playlist
Error message
Expected duration in m3u playlist
What it means
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.
Source
Thrown at packages/media-parser/src/containers/m3u/get-playlist.ts:59
export const getPlaylist = (
structure: M3uStructure,
src: string,
): M3uPlaylist => {
const allPlaylists = getAllPlaylists({structure, src});
const playlists = allPlaylists.find((box) => box.src === src);
if (!playlists) {
throw new Error(`Expected m3u-playlist with src ${src}`);
}
return playlists as M3uPlaylist;
};
export const getDurationFromPlaylist = (playlist: M3uPlaylist): number => {
const duration = playlist.boxes.filter((box) => box.type === 'm3u-extinf');
if (duration.length === 0) {
throw new Error('Expected duration in m3u playlist');
}
return duration.reduce((acc, d) => acc + d.value, 0);
};
View on GitHub (pinned to 78fe4bb3fd)
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
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-fetch the media playlist and check for EXTINF lines
const text = await (await fetch(playlistUrl)).text();
if (!text.includes('#EXTINF')) {
throw new Error('Playlist has no segments — not ready for parsing');
} Try / catch
try {
await parseMedia({src: playlistUrl});
} catch (e) {
if (e instanceof Error && e.message === 'Expected duration in m3u playlist') {
// playlist has no segments — for live streams, retry after a delay
}
throw e;
} Prevention
- For live HLS streams, wait until segments are published before parsing
- Check playlist content manually if the stream origin may serve empty playlists
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Expected m3u-text-value
- EXTINF has no value
- No streams found
- No moov box found in header segment
- Stream does not have a resolution
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/a61c6fb8b258ac6a.
Report an issue: GitHub.