diff --git a/stringify.ts b/stringify.ts index 62de521..a04d3e3 100644 --- a/stringify.ts +++ b/stringify.ts @@ -363,8 +363,10 @@ function buildSegment(lines: LineArray, segment: Segment, lastKey: string, lastM if (hint) { return [lastKey, lastMap]; } - const duration = version < 3 ? Math.round(segment.duration) : buildDecimalFloatingNumber(segment.duration, getNumberOfDecimalPlaces(segment.duration)); - lines.push(`#EXTINF:${duration},${unescape(encodeURIComponent(segment.title || ''))}`); + if (typeof segment.duration === 'number' && !Number.isNaN(segment.duration)) { + const duration = version < 3 ? Math.round(segment.duration) : buildDecimalFloatingNumber(segment.duration, getNumberOfDecimalPlaces(segment.duration)); + lines.push(`#EXTINF:${duration},${unescape(encodeURIComponent(segment.title || ''))}`); + } if (segment.byterange) { lines.push(`#EXT-X-BYTERANGE:${buildByteRange(segment.byterange)}`); } diff --git a/test/spec/Apple-Low-Latency/New_Media_Playlist_Tags_for_Low-Latency_HLS/03_EXT-X-PART.spec.js b/test/spec/Apple-Low-Latency/New_Media_Playlist_Tags_for_Low-Latency_HLS/03_EXT-X-PART.spec.js index c883b0d..926da60 100644 --- a/test/spec/Apple-Low-Latency/New_Media_Playlist_Tags_for_Low-Latency_HLS/03_EXT-X-PART.spec.js +++ b/test/spec/Apple-Low-Latency/New_Media_Playlist_Tags_for_Low-Latency_HLS/03_EXT-X-PART.spec.js @@ -216,3 +216,18 @@ test('#EXT-X-PART_05', t => { } } }); + +// EXTINF can be ommitted +test('#EXT-X-PART_06', t => { + utils.bothPass(t, ` + #EXTM3U + #EXT-X-VERSION:6 + #EXT-X-TARGETDURATION:2 + #EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK=0.6 + #EXT-X-PART-INF:PART-TARGET=0.2 + #EXTINF:2, + fs240.mp4 + #EXT-X-PART:DURATION=0.17,URI="fs241.mp4",BYTERANGE=20000@0 + #EXT-X-ENDLIST + `); +});