{"library":"m3u8-parser","title":"M3U8 Playlist Parser","description":"m3u8-parser is a JavaScript library designed for parsing M3U8 HLS (HTTP Live Streaming) manifests. It provides a robust, standalone mechanism to interpret the structure and metadata of HLS playlists, converting them into a structured JavaScript object. Currently at version 7.2.0, the package maintains an active development pace, regularly incorporating support for new HLS tags and specifications, as evidenced by recent feature additions in minor releases (e.g., #EXT-X-I-FRAME-STREAM-INF, #EXT-X-I-FRAMES-ONLY, #EXT-X-DEFINE). Originating from the Video.js ecosystem, it has since become an independent utility, removing its direct dependency on Video.js in version 1.0.1. Its key differentiators include comprehensive HLS tag support, extensibility through custom parsers, and the ability to handle constructor options for advanced features like variable replacement with #EXT-X-DEFINE, making it suitable for both simple manifest interpretation and complex HLS stream management.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install m3u8-parser"],"cli":null},"imports":["import { Parser } from 'm3u8-parser';","const m3u8Parser = require('m3u8-parser');","const parser = new m3u8Parser.Parser();"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const manifest = [\n  '#EXTM3U',\n  '#EXT-X-VERSION:3',\n  '#EXT-X-TARGETDURATION:6',\n  '#EXT-X-MEDIA-SEQUENCE:0',\n  '#EXT-X-DISCONTINUITY-SEQUENCE:0',\n  '#EXTINF:6,',\n  '0.ts',\n  '#EXTINF:6,',\n  '1.ts',\n  '#EXT-X-PROGRAM-DATE-TIME:2019-02-14T02:14:00.106Z',\n  '#EXTINF:6,',\n  '2.ts',\n  '#EXT-X-ENDLIST'\n].join('\\n');\n\n// Import the Parser class depending on your environment\n// CommonJS:\nconst m3u8Parser = require('m3u8-parser');\nconst parser = new m3u8Parser.Parser();\n\n// ESM:\n// import { Parser } from 'm3u8-parser';\n// const parser = new Parser();\n\n// Push the manifest string into the parser\nparser.push(manifest);\nparser.end(); // Signal that no more data will be pushed\n\n// Access the parsed manifest object\nconst parsedManifest = parser.manifest;\n\nconsole.log('Manifest parsed successfully!');\nconsole.log('Is end list:', parsedManifest.endList);\nconsole.log('Target duration:', parsedManifest.targetDuration);\nconsole.log('Number of segments:', parsedManifest.segments.length);\nif (parsedManifest.segments.length > 0) {\n  console.log('First segment URI:', parsedManifest.segments[0].uri);\n  console.log('First segment duration:', parsedManifest.segments[0].duration);\n}\n","lang":"javascript","description":"This quickstart demonstrates how to instantiate the m3u8-parser, feed it an HLS manifest string, and access the resulting structured JavaScript object containing parsed playlist information. It shows basic manifest creation, parsing, and logging of key properties like endList status, target duration, and segment details.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}