parse-m3u8
A Node.js module to parse M3U8
const parseM3u8 = ; segments; /*=> [ { duration: 10, uri: '0.ts', timeline: 0 }, { duration: 20, uri: '1.ts', timeline: 0 }] */
Installation
npm install parse-m3u8
API
const parseM3u8 = ;
parseM3u8(contents [, option])
contents: string
option: Object
Return: Object
It parses a given string
with m3u8-parser and returns a result Object
.
option.baseUri
Type: string | URL
Rebase uri
properties of each items in playlists
and segments
to this URL.
const source = `#EXTM3U#EXT-X-STREAM-INF:BANDWIDTH=300000low.m3u8#EXT-X-STREAM-INF:BANDWIDTH=600000high.m3u8`; playlists; /*=> [ { attributes: {BANDWIDTH: 300000}, uri: 'low.m3u8', timeline: 0 }, { attributes: {BANDWIDTH: 600000}, uri: 'high.m3u8', timeline: 0 }] */ playlists; /*=> [ { attributes: {BANDWIDTH: 300000}, uri: 'https://example.org/assets/playlists/low.m3u8', timeline: 0 }, { attributes: {BANDWIDTH: 600000}, uri: 'https://example.org/assets/playlists/high.m3u8', timeline: 0 }] */
License
ISC License © 2018 - 2019 Watanabe Shinnosuke