jmuxer 2.0.6 → 2.1.0
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 +24 -33
- package/dist/jmuxer.min.js +3416 -1
- package/package.json +12 -6
- package/src/controller/remux.js +63 -46
- package/src/jmuxer.js +42 -147
- package/src/parsers/aac.js +13 -38
- package/src/parsers/h264.js +101 -96
- package/src/parsers/h265.js +303 -0
- package/src/remuxer/aac.js +63 -7
- package/src/remuxer/base.js +2 -1
- package/src/remuxer/h264.js +163 -7
- package/src/remuxer/h265.js +288 -0
- package/src/util/debug.js +3 -3
- package/src/util/event.js +2 -2
- package/src/util/mp4-generator.js +124 -9
- package/test/parser.js +20 -21
- package/loader-thumb.jpg +0 -0
- package/packet-format.png +0 -0
- package/src/util/nalu.js +0 -73
package/test/parser.js
CHANGED
|
@@ -10,27 +10,26 @@ var aac = new Uint8Array([255, 241, 80, 128, 35, 159, 252, 33, 10, 84, 140, 49,
|
|
|
10
10
|
|
|
11
11
|
describe('Parser tests --', function() {
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
it('Number of extracted h264 NAL unit should be 2', function() {
|
|
14
|
+
var result = H264Parser.extractNALu(h264);
|
|
15
|
+
assert.equal(result.length, 2);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('AAC pattern should return true', function() {
|
|
19
|
+
assert.equal(AACParser.isAACPattern(aac), true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('AAC header length should be 7 since CRC not present', function() {
|
|
23
|
+
assert.equal(AACParser.getHeaderLength(aac), 7);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('AAC frame length should be 284', function() {
|
|
27
|
+
assert.equal(AACParser.getFrameLength(aac), 284);
|
|
28
|
+
});
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
30
|
+
it('Number of extracted AAC frames should be 1', function() {
|
|
31
|
+
var result = AACParser.extractAAC(aac);
|
|
32
|
+
assert.equal(result.length, 1);
|
|
33
|
+
});
|
|
35
34
|
});
|
|
36
35
|
|
package/loader-thumb.jpg
DELETED
|
Binary file
|
package/packet-format.png
DELETED
|
Binary file
|
package/src/util/nalu.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export class NALU {
|
|
2
|
-
|
|
3
|
-
static get NDR() { return 1; }
|
|
4
|
-
static get IDR() { return 5; }
|
|
5
|
-
static get SEI() { return 6; }
|
|
6
|
-
static get SPS() { return 7; }
|
|
7
|
-
static get PPS() { return 8; }
|
|
8
|
-
static get AUD() { return 9; }
|
|
9
|
-
|
|
10
|
-
static get TYPES() {
|
|
11
|
-
return {
|
|
12
|
-
[NALU.IDR]: 'IDR',
|
|
13
|
-
[NALU.SEI]: 'SEI',
|
|
14
|
-
[NALU.SPS]: 'SPS',
|
|
15
|
-
[NALU.PPS]: 'PPS',
|
|
16
|
-
[NALU.NDR]: 'NDR',
|
|
17
|
-
[NALU.AUD]: 'AUD',
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static type(nalu) {
|
|
22
|
-
if (nalu.ntype in NALU.TYPES) {
|
|
23
|
-
return NALU.TYPES[nalu.ntype];
|
|
24
|
-
} else {
|
|
25
|
-
return 'UNKNOWN';
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
constructor(data) {
|
|
30
|
-
this.payload = data;
|
|
31
|
-
this.nri = (this.payload[0] & 0x60) >> 5; // nal_ref_idc
|
|
32
|
-
this.ntype = this.payload[0] & 0x1f;
|
|
33
|
-
this.isvcl = this.ntype == 1 || this.ntype == 5;
|
|
34
|
-
this.stype = ''; // slice_type
|
|
35
|
-
this.isfmb = false; // first_mb_in_slice
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
toString() {
|
|
39
|
-
return `${NALU.type(this)}: NRI: ${this.getNri()}`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
getNri() {
|
|
43
|
-
return this.nri;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type() {
|
|
47
|
-
return this.ntype;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
isKeyframe() {
|
|
51
|
-
return this.ntype === NALU.IDR;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
getPayload() {
|
|
55
|
-
return this.payload;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
getPayloadSize() {
|
|
59
|
-
return this.payload.byteLength;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
getSize() {
|
|
63
|
-
return 4 + this.getPayloadSize();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
getData() {
|
|
67
|
-
const result = new Uint8Array(this.getSize());
|
|
68
|
-
const view = new DataView(result.buffer);
|
|
69
|
-
view.setUint32(0, this.getSize() - 4);
|
|
70
|
-
result.set(this.getPayload(), 4);
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
}
|