videojs / m3u8-parser Goto Github PK
View Code? Open in Web Editor NEWAn m3u8 parser.
License: Other
An m3u8 parser.
License: Other
EXT-X-MAP is not parsed correctly. It does not appear in the parsed output. This is because the map() function does not add anything to the manifest:
https://github.com/videojs/m3u8-parser/blob/main/src/parser.js#L368
Microsoft also made some contribution into HLS format, to support their PlayReady DRM.
I don't have alive HLS stream with PlayReady to check, and actually I am not sure, how to test playback here, because with the death of old Edge there are no more browsers with PlayReady support on the desktop platform, as far as I know.
But I think minimal change need to be done to avoid issue like #139, filter out EXT-X-KEY
rows with KEYFORMAT="com.microsoft.playready"
Hi!
I found a nice memory leak issue in Chromium based browsers due to a V8 engine string slicing problem.
More about it here: https://bugs.chromium.org/p/v8/issues/detail?id=2869
This causes a longer DVR live stream (tested with 10 hours long) to crash in 30-40 minutes in video.js 7+ due to extreme memory consuption.
A possible solution is just a small hack that's required for every parsed string.
For example:
if (line[0] !== "#") {
this.trigger("data", {
type: "uri",
uri: (" " + line).substring(1), // <-------
});
return;
}
match = /^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(newLine);
if (match) {
event = {
type: 'tag',
tagType: 'program-date-time'
};
if (match[1]) {
event.dateTimeString = (" " + match[1]).substring(1); // <-------
event.dateTimeObject = new Date(match[1]);
}
this.trigger('data', event);
return;
}
These modifications reduced the players memory consuption from 2 GB to 30 MB.
Best regards,
zsilbi
Hi, I want to suggest a small improvement for your parser.
I am using a parser for this file https://test-streams.mux.dev/x36xhzz/url_6/193039199_mp4_h264_aac_hq_7.m3u8
The famous cartoon about a fat rabbit.
It would be cool to add, in addition to the segments, the address "https://test-streams.mux.dev/x36xhzz/url_6/" where the segment files are located.
manifest={allowCache: true
location: "https://test-streams.mux.dev/x36xhzz/url_6/",
discontinuitySequence: 0,
discontinuityStarts: [],
endList: true,
mediaSequence: 0,
playlistType: "VOD",
segments: (64) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}],
targetDuration: 11}
In the m3u8 file:
Total subtitles tracks are 2 tracks
But using m3u8-parser, total subtitles track is only 1 track
let parser = new m3u8Parser.Parser();
parser.push(response.body);
text_tracks = parser.manifest.mediaGroups.SUBTITLES;
Note: response.body is the content of the m3u8 file (in the attachment)
test.txt
Env: Ubuntu 18.04, m3u8-parser version 4.4.0
how to get manifest infomation by videojs related to manifest size , download duration and failure stats ?
#EXT-X-PROGRAM-DATE-TIME is a media segment tag but we treat it as a media playlist tag
After I use parser.push(), the content cannot be erased.
If I wish to parse one new m3u8, how can I use the API?
4.1.3
to 4.1.4
.This version is covered by your current version range and after updating it in your project the build failed.
npm-run-all is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
1.1.4
to 1.2.0
.This version is covered by your current version range and after updating it in your project the build failed.
husky is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 6 commits.
d6ecea2
1.2.0
98641f5
Update CHANGELOG.md
c5372b3
Add debug message (#399)
57cb3b9
Add generated by informations in hook script (#400)
d4f7531
Update README.md
fdca003
Update README.md
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
how to get M3U8 manifest infomation by videojs?
https://developer.roku.com/en-ca/docs/developer-program/media-playback/trick-mode/hls-and-dash.md
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:54
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-IMAGES-ONLY
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000001.jpg
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000002.jpg
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000003.jpg
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000004.jpg
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000005.jpg
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000006.jpg
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000007.jpg
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000008.jpg
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000009.jpg
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000010.jpg
#EXTINF:54,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=6
Thumbnail_000000011.jpg
#EXTINF:2,
#EXT-X-TILES:RESOLUTION=312x176,LAYOUT=3x3,DURATION=2
Thumbnail_000000012.jpg
#EXT-X-ENDLIST
Hello, my project crash with m3u8-parser (4.5.1) and MR #118 @brandonocasey
Environment: Linux
Tested on Windows and working but not on Linux, and working with downgrade to 4.5.0 with Linux.
/root/project/node_modules/@videojs/vhs-utils/es/stream.js:121
export { Stream as default };
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (internal/modules/cjs/loader.js:1116:16)
at Module._compile (internal/modules/cjs/loader.js:1164:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/root/project/node_modules/m3u8-parser/dist/m3u8-parser.cjs.js:9:30)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/root/project/src/m3u8.ts:3:20)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
1.3.1
to 1.4.0
.This version is covered by your current version range and after updating it in your project the build failed.
doctoc is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Is there a way to turn a parsed manifest back into m3u8 format? I need to parse, modify, and then save an m3u8 file and I can't tell how save the manifest back to text format.
Hi, I saw that a m3u8 file can be "basic" or "extended".
eg. A basic line for a track would be
#EXTINF:240,Artist - Title
While extended would be
#EXTINF:240,a=Artist,t=Title
Could your parser support this ?
By the way, I noticed title is not returned at all ?
Related to #158 ?
2.0.5
to 2.0.7
.This version is covered by your current version range and after updating it in your project the build failed.
conventional-changelog-cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
If you parse an empty media playlist, you should receive an empty segments array, not undefined. That is, this (clearly invalid) m3u8:
#EXTM3U
should produce an object with this shape:
{
segments: []
}
How I can make reverse engineer, get m3u8 generated string from Manifest Object? My purpose it's analyze the manifest, delete some items, and regenerate the manifest
Hi,
this is a valid item (with multiple URLs).
#EXTINF:-1,a=Artist 3,t=Song 3
http://example.com/song3.mp3
http://example.com/song3-live.mp3
It should return a single segment with multiple URLs, but returns multiple segments instead.
While it's cool that metadata like #EXT-X-DISCONTINUITY
maps to segments[0].discontinuity = true
, would it be possible at all to also have some object within the segment that is an array of all the expressions that were parsed?
Since right now the plugin can't be used to reverse build the manifest (which I don't actually need anyway), I'm looking to easily store the actual expressions for easily rebuilding chunklists later.
Greetings
I'm using VideoJS with HLS and I'm receiving exceptions for this line:
attr = (/([^=]*)=(.*)/).exec(attrs[i]).slice(1);
(parse-stream.js
line 40)
The problem is, the attribute array is like this:
1:"PROGRAM-ID=1"
2:""
3:"BANDWIDTH=650000"
4:""
5:"RESOLUTION=600x356"
6:""
7:"CODECS=avc1.66.31"
8:",mp4a.40.2"
probably because it's parsed from a m3u8 manifest.
On the first line parsed, line 8, the regex returns undefined
so there is no slice()
method.
I'm not sure if parseAttributes()
should be receiving this, but it definitely should check the regex result before using it.
The offset
portion of the EXT-X-BYTERANGE
tag is optional, and should be calculated using the previous segment's offset and bytelength, however the parser currently just assumes a missing offset should default to 0.
https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.2.2
If o is not present, the sub-range begins at the next byte following the sub-range of the previous Media Segment.
3.1.1
to 3.1.2
.This version is covered by your current version range and after updating it in your project the build failed.
karma is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 11 commits.
7d4d347
chore: release v3.1.2
5077c18
chore: update contributors
fb05fb1
fix(server): use flatted for json.stringify (#3220)
2682bff
feat(docs): callout the key debug strategies. (#3219)
4e87902
fix(changelog): remove release which does not exist (#3214)
30ff73b
fix(browser): report errors to console during singleRun=false (#3209)
5334d1a
fix(file-list): do not preprocess up-to-date files (#3196)
dc5f5de
fix(deps): upgrade sinon-chai 2.x -> 3.x (#3207)
d38f344
fix(package): bump lodash version (#3203)
ffb41f9
refactor(browser): log state transitions in debug (#3202)
240209f
fix(dep): Bump useragent to fix HeadlessChrome version (#3201)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Hi,
I was wondering if there was a simple way to parse an m3u8 using this and to return a simple true/false on whether the m3u8 is working?
Thanks!
The latest GitHub release is 4.3.0 whereas the latest npm release is 4.7.0.
Looks like stream, configured with multi-drm setup, Widevine + Fairplay, conflicts with AES-128 encryption detection.
In my m3u8 playlist there are two EXT-X-KEY
rows, like
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="data:text/plain;base64,...",KEYID=...,IV=...,KEYFORMATVERSIONS="1",KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://...",KEYFORMATVERSIONS="1",KEYFORMAT="com.apple.streamingkeydelivery"
First one — is for Widevine, second one is for Fairplay.
This stream is correctly played in Safari, but not in Chrome.
Parser correctly recognises Widevine options, but second row is recognised like AES-128 key for segments. And later, VideoJS segment loader fails to load "key" by skd://
URL, thus failing to play stream.
Shaka Player plays this stream in Chrome without errors, I guess, because there is no AES-128 support in it (shaka-project/shaka-player#850).
We have a vtt playlist with non standard #EXT-X-MEDIA-TIME tag:
#EXT-X-MEDIA-TIME:0.0
The parser then tries to parse the attributes from "-TIME:0.0" probably because it somehow detects this as the #EXT-X-MEDIA tag.
This causes this exception here: attr = /([^=]*)=(.*)/.exec(attrs[i]).slice(1);
Exception has occurred: TypeError
TypeError: Cannot read property 'slice' of null
at parseAttributes (/Users/ost/Development/adaptive_playground/Server/node_modules/m3u8-parser/es5/parse-stream.js:60:41)
at ParseStream.push (/Users/ost/Development/adaptive_playground/Server/node_modules/m3u8-parser/es5/parse-stream.js:339:30)
at LineStream. (/Users/ost/Development/adaptive_playground/Server/node_modules/m3u8-parser/es5/stream.js:124:21)
at LineStream.trigger (/Users/ost/Development/adaptive_playground/Server/node_modules/m3u8-parser/es5/stream.js:91:24)
at LineStream.push (/Users/ost/Development/adaptive_playground/Server/node_modules/m3u8-parser/es5/line-stream.js:59:14)
at Parser.push (/Users/ost/Development/adaptive_playground/Server/node_modules/m3u8-parser/es5/parser.js:370:23)
Probably because of the unneeded '?' after the ':'
match = /^#EXT-X-MEDIA:?(.*)$/.exec(line);
1.27.6
to 1.27.7
.This version is covered by your current version range and after updating it in your project the build failed.
rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
2019-12-01
The new version differs by 4 commits.
c753a7f
1.27.7
1b8a3de
Update changelog
d5651be
Fix incomplete computed property deoptimization (#3267)
d7e3993
Update changelog
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
dependency
@babel/runtime was updated from 7.7.7
to 7.8.0
.This version is covered by your current version range and after updating it in your project the build failed.
This monorepo update includes releases of one or more dependencies which all belong to the babel7 group definition.
babel7 is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
1.18.0
to 1.19.0
.This version is covered by your current version range and after updating it in your project the build failed.
rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 6 commits.
9af119d
1.19.0
b3f361c
Update changelog
456f4d2
Avoid variable from empty module name be empty (#3026)
17eaa43
Use id of last module in chunk as name base for auto-generated chunks (#3025)
871bfa0
Switch to a code-splitting build and update dependencies (#3020)
2443783
Unified file emission api (#2999)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
1.1.3
to 1.1.4
.This version is covered by your current version range and after updating it in your project the build failed.
husky is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 9 commits.
4a9814c
1.1.4
9df8d08
Update CHANGELOG.md
58965b4
Refactor
d32682c
Update README.md
3170033
source file (#397)
209a6ea
Update CHANGELOG.md
da4d9d2
Upgrade execa to 1.0 (#393)
79e1dd9
Update README.md
f3a923d
Update README.md
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Despite declaring m3u8-parser
in global.d.ts
, it doesn't seem to work and when trying to install types with npm , it says unauthorized header.
I'd like to see support for the parsing of#EXT-X-I-FRAME-STREAM-INF
lines.
eg
#EXT-X-I-FRAME-STREAM-INF: BANDWIDTH=100403,RESOLUTION=392x216,CODECS="avc1.42c01e",URI="QualityLevels(90258)/Manifest(video,format=m3u8-aapl,type=keyframes)"
I tried to make a custom parser for this, but I cant seem to get it to work right with an object for each time this line occurs (many times)
Any ideas welcome,
Thanks!
Hi there,
how can I parse title from the extint?
reference
I create
parser.addParser({
expression: /#EXTINF/,
customType: 'audio',
segment: true,
dataParser: function (line) {
const valuePart = line.split(':')
const values = valuePart[1].split(',')
const duration = parseFloat(values[0])
const title = values[1]
return {
duration,
title
};
}
});
but only work for the last item, and the segment doesn't contain anything
I want to read the "EXT-OATCLS-SCTE35" tag in M3U8 in an HLS.
I have tried reading it using player.tech().hls.playlists.media().segments but no luck.
Please help.
If parsing a non-master playlist, or a master playlist where the variants do not have attributes, the attributes
property on the resulting playlist object is undefined
. We should always initialize this to an empty object.
Hi, can you please add support (or any kind of skipping) for wiseplay in playlist?
example:
var wisePlayUri = 'urn:uuid:3d5e6d35-9b9a-41e8-b843-dd3c6e72c42c';
var widevineUuid = 'urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed'; // group segments into numbered timelines delineated by discontinuities`
if (entry.attributes.KEYFORMAT === wisePlayUri) {
this.trigger('warn', {
message: 'wiseplay support should be implemented!'
});
return;
}
if (entry.attributes.KEYFORMAT === widevineUuid) {
var VALID_METHODS = ['SAMPLE-AES', 'SAMPLE-AES-CTR', 'SAMPLE-AES-CENC'];
if (VALID_METHODS.indexOf(entry.attributes.METHOD) === -1) {
this.trigger('warn', {
message: 'invalid key method provided for Widevine'
});
return;
}
if (entry.attributes.METHOD === 'SAMPLE-AES-CENC') {
this.trigger('warn', {
message: 'SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead'
});
}
if (entry.attributes.URI.substring(0, 23) !== 'data:text/plain;base64,') {
this.trigger('warn', {
message: 'invalid key URI provided for Widevine'
});
return;
}
if (!(entry.attributes.KEYID && entry.attributes.KEYID.substring(0, 2) === '0x')) {
this.trigger('warn', {
message: 'invalid key ID provided for Widevine'
});
return;
}
// if Widevine key attributes are valid, store them as `contentProtection`
// on the manifest to emulate Widevine tag structure in a DASH mpd
this.manifest.contentProtection = this.manifest.contentProtection || {};
this.manifest.contentProtection['com.widevine.alpha'] = {
attributes: {
schemeIdUri: entry.attributes.KEYFORMAT,
// remove '0x' from the key id string
keyId: entry.attributes.KEYID.substring(2)
},
// decode the base64-encoded PSSH box
pssh: decodeB64ToUint8Array(entry.attributes.URI.split(',')[1])
};
console.debug('::: ', this.manifest.contentProtection['com.widevine.alpha'])
return;
}
Is this necessary or can it be moved to devDependencies? This is causing babel to be unnecessarily installed in production deployments for us.
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
I am developing a media downloader or transfer based on this.
There are many cases that I need to change the href or location of the segment, is there any possible to change it baesd on this interface?
How do I get the JSON structure back out as a .m3u8 file?
My use case is that I simply need to add a NAME & RENDITION-ID to each item.
Btw my employers are Brightcove customers.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.