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