dasha 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/manifest.js +3 -3
- package/lib/utils.js +14 -9
- package/package.json +2 -2
package/README.md
CHANGED
package/lib/manifest.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { parseXml } = require('./xml');
|
|
4
4
|
const { processManifest } = require('./processor');
|
|
5
|
-
const { getQualityLabel } = require('./utils');
|
|
5
|
+
const { getQualityLabel, getHeightByWidth } = require('./utils');
|
|
6
6
|
const { CONTENT_TYPE, KEY_SYSTEMS } = require('./constants');
|
|
7
7
|
|
|
8
8
|
const isUrl = (value) => {
|
|
@@ -34,7 +34,7 @@ class Manifest {
|
|
|
34
34
|
.flat(1)
|
|
35
35
|
.filter(isVideoAdaptationSet);
|
|
36
36
|
const representations = adaptationSets.map((a) => a.representations).flat(2);
|
|
37
|
-
const matchesInHeight = representations.filter((r) => r.
|
|
37
|
+
const matchesInHeight = representations.filter((r) => getHeightByWidth(r.width) === height);
|
|
38
38
|
const matchesInId = representations.filter((r) => r.id.includes(height));
|
|
39
39
|
const matches = matchesInHeight?.length ? matchesInHeight : matchesInId;
|
|
40
40
|
const representation = this.findBestRepresentation(matches.length ? matches : representations);
|
|
@@ -49,7 +49,7 @@ class Manifest {
|
|
|
49
49
|
size: Math.ceil((representation.bandwidth / 8e6) * this.mediaPresentationDuration), // MB
|
|
50
50
|
width: representation.width,
|
|
51
51
|
height: representation.height,
|
|
52
|
-
|
|
52
|
+
qualityLabel: getQualityLabel(representation.width),
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
package/lib/utils.js
CHANGED
|
@@ -34,16 +34,21 @@ const parseDuration = (durationString) => {
|
|
|
34
34
|
return isFinite(d) ? d : null;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const getHeightByWidth = (videoWidth) => {
|
|
38
38
|
const width = typeof videoWidth === 'number' ? videoWidth : parseInt(videoWidth);
|
|
39
39
|
if (isNaN(width)) return;
|
|
40
|
-
let
|
|
41
|
-
if (width >=
|
|
42
|
-
if (width >=
|
|
43
|
-
if (width >=
|
|
44
|
-
if (width >=
|
|
45
|
-
if (width >=
|
|
46
|
-
|
|
40
|
+
let height = 144;
|
|
41
|
+
if (width >= 426) height = 240;
|
|
42
|
+
if (width >= 640) height = 360;
|
|
43
|
+
if (width >= 854) height = 480;
|
|
44
|
+
if (width >= 1024) height = 576;
|
|
45
|
+
if (width >= 1280) height = 720;
|
|
46
|
+
if (width >= 1920) height = 1080;
|
|
47
|
+
if (width >= 3840) height = 2160;
|
|
48
|
+
if (width >= 7680) height = 4320;
|
|
49
|
+
return height;
|
|
47
50
|
};
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
const getQualityLabel = (videoWidth) => getHeightByWidth(videoWidth) + 'p';
|
|
53
|
+
|
|
54
|
+
module.exports = { parseDuration, getHeightByWidth, getQualityLabel };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dasha",
|
|
3
|
-
"version": "2.3.
|
|
4
|
-
"author": "Vitaly Gashkov <vitalygashkov@
|
|
3
|
+
"version": "2.3.1",
|
|
4
|
+
"author": "Vitaly Gashkov <vitalygashkov@bk.ru>",
|
|
5
5
|
"description": "MPD-manifest parser for MPEG DASH",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"keywords": [
|