music-metadata 10.0.1 → 10.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.
Files changed (122) hide show
  1. package/LICENSE.txt +9 -9
  2. package/README.md +520 -520
  3. package/lib/ParserFactory.d.ts +20 -28
  4. package/lib/ParserFactory.js +204 -207
  5. package/lib/aiff/AiffParser.js +20 -18
  6. package/lib/aiff/AiffToken.d.ts +14 -2
  7. package/lib/aiff/AiffToken.js +12 -0
  8. package/lib/apev2/APEv2Parser.d.ts +4 -4
  9. package/lib/apev2/APEv2Parser.js +12 -10
  10. package/lib/apev2/APEv2Token.d.ts +2 -4
  11. package/lib/apev2/APEv2Token.js +0 -3
  12. package/lib/asf/AsfObject.d.ts +7 -16
  13. package/lib/asf/AsfObject.js +8 -34
  14. package/lib/asf/AsfParser.js +17 -10
  15. package/lib/asf/AsfTagMapper.d.ts +1 -1
  16. package/lib/asf/AsfTagMapper.js +3 -2
  17. package/lib/asf/AsfUtil.d.ts +3 -11
  18. package/lib/asf/AsfUtil.js +29 -30
  19. package/lib/asf/GUID.js +6 -9
  20. package/lib/common/BasicParser.d.ts +4 -4
  21. package/lib/common/BasicParser.js +6 -0
  22. package/lib/common/CaseInsensitiveTagMap.d.ts +1 -1
  23. package/lib/common/CombinedTagMapper.d.ts +5 -5
  24. package/lib/common/CombinedTagMapper.js +1 -1
  25. package/lib/common/FourCC.d.ts +1 -1
  26. package/lib/common/GenericTagMapper.d.ts +8 -8
  27. package/lib/common/GenericTagMapper.js +4 -4
  28. package/lib/common/GenericTagTypes.d.ts +5 -4
  29. package/lib/common/GenericTagTypes.js +2 -2
  30. package/lib/common/MetadataCollector.d.ts +9 -9
  31. package/lib/common/MetadataCollector.js +24 -17
  32. package/lib/common/RandomFileReader.d.ts +1 -1
  33. package/lib/common/RandomFileReader.js +1 -1
  34. package/lib/common/RandomUint8ArrayReader.d.ts +1 -1
  35. package/lib/common/Util.d.ts +2 -6
  36. package/lib/common/Util.js +9 -11
  37. package/lib/core.d.ts +7 -9
  38. package/lib/core.js +10 -7
  39. package/lib/dsdiff/DsdiffParser.js +26 -14
  40. package/lib/dsdiff/DsdiffToken.d.ts +2 -2
  41. package/lib/dsdiff/DsdiffToken.js +1 -0
  42. package/lib/dsf/DsfChunk.js +1 -0
  43. package/lib/dsf/DsfParser.js +4 -2
  44. package/lib/flac/FlacParser.d.ts +3 -3
  45. package/lib/flac/FlacParser.js +9 -12
  46. package/lib/id3v1/ID3v1Parser.d.ts +1 -1
  47. package/lib/id3v1/ID3v1Parser.js +7 -4
  48. package/lib/id3v2/AbstractID3Parser.d.ts +1 -1
  49. package/lib/id3v2/AbstractID3Parser.js +2 -1
  50. package/lib/id3v2/FrameParser.d.ts +28 -3
  51. package/lib/id3v2/FrameParser.js +50 -28
  52. package/lib/id3v2/ID3v22TagMapper.d.ts +1 -1
  53. package/lib/id3v2/ID3v24TagMapper.d.ts +2 -1
  54. package/lib/id3v2/ID3v24TagMapper.js +23 -16
  55. package/lib/id3v2/ID3v2Parser.d.ts +2 -2
  56. package/lib/id3v2/ID3v2Parser.js +19 -8
  57. package/lib/iff/index.js +1 -0
  58. package/lib/index.d.ts +5 -6
  59. package/lib/index.js +7 -8
  60. package/lib/lyrics3/Lyrics3.d.ts +1 -1
  61. package/lib/lyrics3/Lyrics3.js +1 -1
  62. package/lib/matroska/MatroskaDtd.d.ts +1 -1
  63. package/lib/matroska/MatroskaDtd.js +139 -138
  64. package/lib/matroska/MatroskaParser.d.ts +4 -4
  65. package/lib/matroska/MatroskaParser.js +12 -12
  66. package/lib/matroska/types.d.ts +6 -4
  67. package/lib/mp4/Atom.d.ts +3 -3
  68. package/lib/mp4/Atom.js +4 -7
  69. package/lib/mp4/AtomToken.js +2 -1
  70. package/lib/mp4/MP4Parser.js +29 -20
  71. package/lib/mp4/MP4TagMapper.d.ts +2 -2
  72. package/lib/mp4/MP4TagMapper.js +1 -1
  73. package/lib/mpeg/ExtendedLameHeader.d.ts +4 -4
  74. package/lib/mpeg/ExtendedLameHeader.js +2 -1
  75. package/lib/mpeg/MpegParser.d.ts +1 -1
  76. package/lib/mpeg/MpegParser.js +145 -96
  77. package/lib/mpeg/ReplayGainDataFormat.d.ts +1 -1
  78. package/lib/mpeg/ReplayGainDataFormat.js +1 -0
  79. package/lib/mpeg/XingTag.d.ts +4 -4
  80. package/lib/mpeg/XingTag.js +5 -4
  81. package/lib/musepack/index.js +1 -0
  82. package/lib/musepack/sv7/BitReader.js +14 -17
  83. package/lib/musepack/sv7/MpcSv7Parser.js +6 -1
  84. package/lib/musepack/sv7/StreamVersion7.js +1 -0
  85. package/lib/musepack/sv8/MpcSv8Parser.js +6 -2
  86. package/lib/musepack/sv8/StreamVersion8.d.ts +1 -1
  87. package/lib/musepack/sv8/StreamVersion8.js +1 -0
  88. package/lib/ogg/Ogg.d.ts +1 -1
  89. package/lib/ogg/Ogg.js +1 -0
  90. package/lib/ogg/OggParser.d.ts +3 -3
  91. package/lib/ogg/OggParser.js +25 -16
  92. package/lib/ogg/opus/Opus.d.ts +1 -1
  93. package/lib/ogg/opus/Opus.js +1 -0
  94. package/lib/ogg/opus/OpusParser.d.ts +4 -4
  95. package/lib/ogg/opus/OpusParser.js +2 -0
  96. package/lib/ogg/speex/Speex.js +1 -0
  97. package/lib/ogg/speex/SpeexParser.d.ts +4 -4
  98. package/lib/ogg/speex/SpeexParser.js +1 -0
  99. package/lib/ogg/theora/Theora.js +1 -0
  100. package/lib/ogg/theora/TheoraParser.d.ts +4 -4
  101. package/lib/ogg/theora/TheoraParser.js +1 -0
  102. package/lib/ogg/vorbis/Vorbis.d.ts +3 -3
  103. package/lib/ogg/vorbis/Vorbis.js +22 -11
  104. package/lib/ogg/vorbis/VorbisDecoder.d.ts +1 -1
  105. package/lib/ogg/vorbis/VorbisDecoder.js +1 -0
  106. package/lib/ogg/vorbis/VorbisParser.d.ts +4 -4
  107. package/lib/ogg/vorbis/VorbisParser.js +3 -2
  108. package/lib/ogg/vorbis/VorbisTagMapper.d.ts +2 -2
  109. package/lib/ogg/vorbis/VorbisTagMapper.js +2 -2
  110. package/lib/riff/RiffChunk.d.ts +3 -3
  111. package/lib/riff/RiffChunk.js +1 -0
  112. package/lib/riff/RiffInfoTagMap.d.ts +1 -1
  113. package/lib/type.d.ts +35 -25
  114. package/lib/wav/BwfChunk.js +1 -0
  115. package/lib/wav/WaveChunk.d.ts +1 -1
  116. package/lib/wav/WaveChunk.js +1 -0
  117. package/lib/wav/WaveParser.js +27 -17
  118. package/lib/wavpack/WavPackParser.d.ts +1 -1
  119. package/lib/wavpack/WavPackParser.js +22 -13
  120. package/lib/wavpack/WavPackToken.d.ts +13 -17
  121. package/lib/wavpack/WavPackToken.js +22 -23
  122. package/package.json +139 -150
package/lib/index.js CHANGED
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * Node.js specific entry point.
3
3
  */
4
- import * as strtok3 from 'strtok3';
4
+ import { fromFile, fromStream } from 'strtok3';
5
5
  import initDebug from 'debug';
6
6
  import { parseFromTokenizer, scanAppendingHeaders } from './core.js';
7
- import { ParserFactory } from './ParserFactory.js';
7
+ import { getParserIdForExtension, parse } from './ParserFactory.js';
8
8
  import { RandomFileReader } from './common/RandomFileReader.js';
9
- export { LyricsContentType, TimestampFormat } from './type.js';
10
- export { parseFromTokenizer, parseBuffer, parseBlob, parseWebStream, selectCover, orderTags, ratingToStars } from './core.js';
9
+ export * from './core.js';
11
10
  const debug = initDebug('music-metadata:parser');
12
11
  /**
13
12
  * Parse audio from Node Stream.Readable
@@ -17,7 +16,7 @@ const debug = initDebug('music-metadata:parser');
17
16
  * @returns Metadata
18
17
  */
19
18
  export async function parseStream(stream, fileInfo, options = {}) {
20
- const tokenizer = await strtok3.fromStream(stream, { fileInfo: typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo });
19
+ const tokenizer = await fromStream(stream, { fileInfo: typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo });
21
20
  return parseFromTokenizer(tokenizer, options);
22
21
  }
23
22
  /**
@@ -28,7 +27,7 @@ export async function parseStream(stream, fileInfo, options = {}) {
28
27
  */
29
28
  export async function parseFile(filePath, options = {}) {
30
29
  debug(`parseFile: ${filePath}`);
31
- const fileTokenizer = await strtok3.fromFile(filePath);
30
+ const fileTokenizer = await fromFile(filePath);
32
31
  const fileReader = await RandomFileReader.init(filePath, fileTokenizer.fileInfo.size);
33
32
  try {
34
33
  await scanAppendingHeaders(fileReader, options);
@@ -37,10 +36,10 @@ export async function parseFile(filePath, options = {}) {
37
36
  await fileReader.close();
38
37
  }
39
38
  try {
40
- const parserName = ParserFactory.getParserIdForExtension(filePath);
39
+ const parserName = getParserIdForExtension(filePath);
41
40
  if (!parserName)
42
41
  debug(' Parser could not be determined by file extension');
43
- return await ParserFactory.parse(fileTokenizer, parserName, options);
42
+ return await parse(fileTokenizer, parserName, options);
44
43
  }
45
44
  finally {
46
45
  await fileTokenizer.close();
@@ -1,3 +1,3 @@
1
- import { IRandomReader } from '../type.js';
1
+ import type { IRandomReader } from '../type.js';
2
2
  export declare const endTag2 = "LYRICS200";
3
3
  export declare function getLyricsHeaderLength(reader: IRandomReader): Promise<number>;
@@ -6,7 +6,7 @@ export async function getLyricsHeaderLength(reader) {
6
6
  const txt = new TextDecoder('latin1').decode(buf);
7
7
  const tag = txt.slice(6);
8
8
  if (tag === endTag2) {
9
- return parseInt(txt.slice(0, 6), 10) + 15;
9
+ return Number.parseInt(txt.slice(0, 6), 10) + 15;
10
10
  }
11
11
  }
12
12
  return 0;
@@ -1,4 +1,4 @@
1
- import { IContainerType } from './types.js';
1
+ import { type IContainerType } from './types.js';
2
2
  /**
3
3
  * Elements of document type description
4
4
  * Derived from https://github.com/tungol/EBML/blob/master/doctypes/matroska.dtd
@@ -6,149 +6,149 @@ import { DataType } from './types.js';
6
6
  * - https://www.matroska.org/technical/specs/index.html
7
7
  */
8
8
  export const elements = {
9
- 0x1a45dfa3: {
9
+ 440786851: {
10
10
  name: 'ebml',
11
11
  container: {
12
- 0x4286: { name: 'ebmlVersion', value: DataType.uint }, // 5.1.1
13
- 0x42f7: { name: 'ebmlReadVersion', value: DataType.uint }, // 5.1.2
14
- 0x42f2: { name: 'ebmlMaxIDWidth', value: DataType.uint }, // 5.1.3
15
- 0x42f3: { name: 'ebmlMaxSizeWidth', value: DataType.uint }, // 5.1.4
16
- 0x4282: { name: 'docType', value: DataType.string }, // 5.1.5
17
- 0x4287: { name: 'docTypeVersion', value: DataType.uint }, // 5.1.6
18
- 0x4285: { name: 'docTypeReadVersion', value: DataType.uint } // 5.1.7
12
+ 17030: { name: 'ebmlVersion', value: DataType.uint }, // 5.1.1
13
+ 17143: { name: 'ebmlReadVersion', value: DataType.uint }, // 5.1.2
14
+ 17138: { name: 'ebmlMaxIDWidth', value: DataType.uint }, // 5.1.3
15
+ 17139: { name: 'ebmlMaxSizeWidth', value: DataType.uint }, // 5.1.4
16
+ 17026: { name: 'docType', value: DataType.string }, // 5.1.5
17
+ 17031: { name: 'docTypeVersion', value: DataType.uint }, // 5.1.6
18
+ 17029: { name: 'docTypeReadVersion', value: DataType.uint } // 5.1.7
19
19
  }
20
20
  },
21
21
  // Matroska segments
22
- 0x18538067: {
22
+ 408125543: {
23
23
  name: 'segment',
24
24
  container: {
25
25
  // Meta Seek Information
26
- 0x114d9b74: {
26
+ 290298740: {
27
27
  name: 'seekHead',
28
28
  container: {
29
- 0x4dbb: {
29
+ 19899: {
30
30
  name: 'seek',
31
31
  container: {
32
- 0x53ab: { name: 'seekId', value: DataType.binary },
33
- 0x53ac: { name: 'seekPosition', value: DataType.uint }
32
+ 21419: { name: 'seekId', value: DataType.binary },
33
+ 21420: { name: 'seekPosition', value: DataType.uint }
34
34
  }
35
35
  }
36
36
  }
37
37
  },
38
38
  // Segment Information
39
- 0x1549a966: {
39
+ 357149030: {
40
40
  name: 'info',
41
41
  container: {
42
- 0x73a4: { name: 'uid', value: DataType.uid },
43
- 0x7384: { name: 'filename', value: DataType.string },
44
- 0x3cb923: { name: 'prevUID', value: DataType.uid },
45
- 0x3c83ab: { name: 'prevFilename', value: DataType.string },
46
- 0x3eb923: { name: 'nextUID', value: DataType.uid },
47
- 0x3e83bb: { name: 'nextFilename', value: DataType.string },
48
- 0x2ad7b1: { name: 'timecodeScale', value: DataType.uint },
49
- 0x4489: { name: 'duration', value: DataType.float },
50
- 0x4461: { name: 'dateUTC', value: DataType.uint },
51
- 0x7ba9: { name: 'title', value: DataType.string },
52
- 0x4d80: { name: 'muxingApp', value: DataType.string },
53
- 0x5741: { name: 'writingApp', value: DataType.string }
42
+ 29604: { name: 'uid', value: DataType.uid },
43
+ 29572: { name: 'filename', value: DataType.string },
44
+ 3979555: { name: 'prevUID', value: DataType.uid },
45
+ 3965867: { name: 'prevFilename', value: DataType.string },
46
+ 4110627: { name: 'nextUID', value: DataType.uid },
47
+ 4096955: { name: 'nextFilename', value: DataType.string },
48
+ 2807729: { name: 'timecodeScale', value: DataType.uint },
49
+ 17545: { name: 'duration', value: DataType.float },
50
+ 17505: { name: 'dateUTC', value: DataType.uint },
51
+ 31657: { name: 'title', value: DataType.string },
52
+ 19840: { name: 'muxingApp', value: DataType.string },
53
+ 22337: { name: 'writingApp', value: DataType.string }
54
54
  }
55
55
  },
56
56
  // Cluster
57
- 0x1f43b675: {
57
+ 524531317: {
58
58
  name: 'cluster',
59
59
  multiple: true,
60
60
  container: {
61
- 0xe7: { name: 'timecode', value: DataType.uid },
62
- 0xa3: { name: 'unknown', value: DataType.binary },
63
- 0xa7: { name: 'position', value: DataType.uid },
64
- 0xab: { name: 'prevSize', value: DataType.uid }
61
+ 231: { name: 'timecode', value: DataType.uid },
62
+ 163: { name: 'unknown', value: DataType.binary },
63
+ 167: { name: 'position', value: DataType.uid },
64
+ 171: { name: 'prevSize', value: DataType.uid }
65
65
  }
66
66
  },
67
67
  // Track
68
- 0x1654ae6b: {
68
+ 374648427: {
69
69
  name: 'tracks',
70
70
  container: {
71
- 0xae: {
71
+ 174: {
72
72
  name: 'entries',
73
73
  multiple: true,
74
74
  container: {
75
- 0xd7: { name: 'trackNumber', value: DataType.uint },
76
- 0x73c5: { name: 'uid', value: DataType.uid },
77
- 0x83: { name: 'trackType', value: DataType.uint },
78
- 0xb9: { name: 'flagEnabled', value: DataType.bool },
79
- 0x88: { name: 'flagDefault', value: DataType.bool },
80
- 0x55aa: { name: 'flagForced', value: DataType.bool }, // extended
81
- 0x9c: { name: 'flagLacing', value: DataType.bool },
82
- 0x6de7: { name: 'minCache', value: DataType.uint },
83
- 0x6de8: { name: 'maxCache', value: DataType.uint },
84
- 0x23e383: { name: 'defaultDuration', value: DataType.uint },
85
- 0x23314f: { name: 'timecodeScale', value: DataType.float },
86
- 0x536e: { name: 'name', value: DataType.string },
87
- 0x22b59c: { name: 'language', value: DataType.string },
88
- 0x86: { name: 'codecID', value: DataType.string },
89
- 0x63a2: { name: 'codecPrivate', value: DataType.binary },
90
- 0x258688: { name: 'codecName', value: DataType.string },
91
- 0x3a9697: { name: 'codecSettings', value: DataType.string },
92
- 0x3b4040: { name: 'codecInfoUrl', value: DataType.string },
93
- 0x26b240: { name: 'codecDownloadUrl', value: DataType.string },
94
- 0xaa: { name: 'codecDecodeAll', value: DataType.bool },
95
- 0x6fab: { name: 'trackOverlay', value: DataType.uint },
75
+ 215: { name: 'trackNumber', value: DataType.uint },
76
+ 29637: { name: 'uid', value: DataType.uid },
77
+ 131: { name: 'trackType', value: DataType.uint },
78
+ 185: { name: 'flagEnabled', value: DataType.bool },
79
+ 136: { name: 'flagDefault', value: DataType.bool },
80
+ 21930: { name: 'flagForced', value: DataType.bool }, // extended
81
+ 156: { name: 'flagLacing', value: DataType.bool },
82
+ 28135: { name: 'minCache', value: DataType.uint },
83
+ 28136: { name: 'maxCache', value: DataType.uint },
84
+ 2352003: { name: 'defaultDuration', value: DataType.uint },
85
+ 2306383: { name: 'timecodeScale', value: DataType.float },
86
+ 21358: { name: 'name', value: DataType.string },
87
+ 2274716: { name: 'language', value: DataType.string },
88
+ 134: { name: 'codecID', value: DataType.string },
89
+ 25506: { name: 'codecPrivate', value: DataType.binary },
90
+ 2459272: { name: 'codecName', value: DataType.string },
91
+ 3839639: { name: 'codecSettings', value: DataType.string },
92
+ 3883072: { name: 'codecInfoUrl', value: DataType.string },
93
+ 2536000: { name: 'codecDownloadUrl', value: DataType.string },
94
+ 170: { name: 'codecDecodeAll', value: DataType.bool },
95
+ 28587: { name: 'trackOverlay', value: DataType.uint },
96
96
  // Video
97
- 0xe0: {
97
+ 224: {
98
98
  name: 'video',
99
99
  container: {
100
- 0x9a: { name: 'flagInterlaced', value: DataType.bool },
101
- 0x53b8: { name: 'stereoMode', value: DataType.uint },
102
- 0xb0: { name: 'pixelWidth', value: DataType.uint },
103
- 0xba: { name: 'pixelHeight', value: DataType.uint },
104
- 0x54b0: { name: 'displayWidth', value: DataType.uint },
105
- 0x54ba: { name: 'displayHeight', value: DataType.uint },
106
- 0x54b3: { name: 'aspectRatioType', value: DataType.uint },
107
- 0x2eb524: { name: 'colourSpace', value: DataType.uint },
108
- 0x2fb523: { name: 'gammaValue', value: DataType.float }
100
+ 154: { name: 'flagInterlaced', value: DataType.bool },
101
+ 21432: { name: 'stereoMode', value: DataType.uint },
102
+ 176: { name: 'pixelWidth', value: DataType.uint },
103
+ 186: { name: 'pixelHeight', value: DataType.uint },
104
+ 21680: { name: 'displayWidth', value: DataType.uint },
105
+ 21690: { name: 'displayHeight', value: DataType.uint },
106
+ 21683: { name: 'aspectRatioType', value: DataType.uint },
107
+ 3061028: { name: 'colourSpace', value: DataType.uint },
108
+ 3126563: { name: 'gammaValue', value: DataType.float }
109
109
  }
110
110
  },
111
111
  // Audio
112
- 0xe1: {
112
+ 225: {
113
113
  name: 'audio',
114
114
  container: {
115
- 0xb5: { name: 'samplingFrequency', value: DataType.float },
116
- 0x78b5: { name: 'outputSamplingFrequency', value: DataType.float },
117
- 0x9f: { name: 'channels', value: DataType.uint }, // https://www.matroska.org/technical/specs/index.html
118
- 0x94: { name: 'channels', value: DataType.uint },
119
- 0x7d7b: { name: 'channelPositions', value: DataType.binary },
120
- 0x6264: { name: 'bitDepth', value: DataType.uint }
115
+ 181: { name: 'samplingFrequency', value: DataType.float },
116
+ 30901: { name: 'outputSamplingFrequency', value: DataType.float },
117
+ 159: { name: 'channels', value: DataType.uint }, // https://www.matroska.org/technical/specs/index.html
118
+ 148: { name: 'channels', value: DataType.uint },
119
+ 32123: { name: 'channelPositions', value: DataType.binary },
120
+ 25188: { name: 'bitDepth', value: DataType.uint }
121
121
  }
122
122
  },
123
123
  // Content Encoding
124
- 0x6d80: {
124
+ 28032: {
125
125
  name: 'contentEncodings',
126
126
  container: {
127
- 0x6240: {
127
+ 25152: {
128
128
  name: 'contentEncoding',
129
129
  container: {
130
- 0x5031: { name: 'order', value: DataType.uint },
131
- 0x5032: { name: 'scope', value: DataType.bool },
132
- 0x5033: { name: 'type', value: DataType.uint },
133
- 0x5034: {
130
+ 20529: { name: 'order', value: DataType.uint },
131
+ 20530: { name: 'scope', value: DataType.bool },
132
+ 20531: { name: 'type', value: DataType.uint },
133
+ 20532: {
134
134
  name: 'contentEncoding',
135
135
  container: {
136
- 0x4254: { name: 'contentCompAlgo', value: DataType.uint },
137
- 0x4255: { name: 'contentCompSettings', value: DataType.binary }
136
+ 16980: { name: 'contentCompAlgo', value: DataType.uint },
137
+ 16981: { name: 'contentCompSettings', value: DataType.binary }
138
138
  }
139
139
  },
140
- 0x5035: {
140
+ 20533: {
141
141
  name: 'contentEncoding',
142
142
  container: {
143
- 0x47e1: { name: 'contentEncAlgo', value: DataType.uint },
144
- 0x47e2: { name: 'contentEncKeyID', value: DataType.binary },
145
- 0x47e3: { name: 'contentSignature ', value: DataType.binary },
146
- 0x47e4: { name: 'ContentSigKeyID ', value: DataType.binary },
147
- 0x47e5: { name: 'contentSigAlgo ', value: DataType.uint },
148
- 0x47e6: { name: 'contentSigHashAlgo ', value: DataType.uint }
143
+ 18401: { name: 'contentEncAlgo', value: DataType.uint },
144
+ 18402: { name: 'contentEncKeyID', value: DataType.binary },
145
+ 18403: { name: 'contentSignature ', value: DataType.binary },
146
+ 18404: { name: 'ContentSigKeyID ', value: DataType.binary },
147
+ 18405: { name: 'contentSigAlgo ', value: DataType.uint },
148
+ 18406: { name: 'contentSigHashAlgo ', value: DataType.uint }
149
149
  }
150
150
  },
151
- 0x6264: { name: 'bitDepth', value: DataType.uint }
151
+ 25188: { name: 'bitDepth', value: DataType.uint }
152
152
  }
153
153
  }
154
154
  }
@@ -158,29 +158,29 @@ export const elements = {
158
158
  }
159
159
  },
160
160
  // Cueing Data
161
- 0x1c53bb6b: {
161
+ 475249515: {
162
162
  name: 'cues',
163
163
  container: {
164
- 0xbb: {
164
+ 187: {
165
165
  name: 'cuePoint',
166
166
  container: {
167
- 0xb3: { name: 'cueTime', value: DataType.uid },
168
- 0xb7: {
167
+ 179: { name: 'cueTime', value: DataType.uid },
168
+ 183: {
169
169
  name: 'positions',
170
170
  container: {
171
- 0xf7: { name: 'track', value: DataType.uint },
172
- 0xf1: { name: 'clusterPosition', value: DataType.uint },
173
- 0x5378: { name: 'blockNumber', value: DataType.uint },
174
- 0xea: { name: 'codecState', value: DataType.uint },
175
- 0xdb: {
171
+ 247: { name: 'track', value: DataType.uint },
172
+ 241: { name: 'clusterPosition', value: DataType.uint },
173
+ 21368: { name: 'blockNumber', value: DataType.uint },
174
+ 234: { name: 'codecState', value: DataType.uint },
175
+ 219: {
176
176
  name: 'reference', container: {
177
- 0x96: { name: 'time', value: DataType.uint },
178
- 0x97: { name: 'cluster', value: DataType.uint },
179
- 0x535f: { name: 'number', value: DataType.uint },
180
- 0xeb: { name: 'codecState', value: DataType.uint }
177
+ 150: { name: 'time', value: DataType.uint },
178
+ 151: { name: 'cluster', value: DataType.uint },
179
+ 21343: { name: 'number', value: DataType.uint },
180
+ 235: { name: 'codecState', value: DataType.uint }
181
181
  }
182
182
  },
183
- 0xf0: { name: 'relativePosition', value: DataType.uint } // extended
183
+ 240: { name: 'relativePosition', value: DataType.uint } // extended
184
184
  }
185
185
  }
186
186
  }
@@ -188,44 +188,44 @@ export const elements = {
188
188
  }
189
189
  },
190
190
  // Attachment
191
- 0x1941a469: {
191
+ 423732329: {
192
192
  name: 'attachments',
193
193
  container: {
194
- 0x61a7: {
194
+ 24999: {
195
195
  name: 'attachedFiles',
196
196
  multiple: true,
197
197
  container: {
198
- 0x467e: { name: 'description', value: DataType.string },
199
- 0x466e: { name: 'name', value: DataType.string },
200
- 0x4660: { name: 'mimeType', value: DataType.string },
201
- 0x465c: { name: 'data', value: DataType.binary },
202
- 0x46ae: { name: 'uid', value: DataType.uid }
198
+ 18046: { name: 'description', value: DataType.string },
199
+ 18030: { name: 'name', value: DataType.string },
200
+ 18016: { name: 'mimeType', value: DataType.string },
201
+ 18012: { name: 'data', value: DataType.binary },
202
+ 18094: { name: 'uid', value: DataType.uid }
203
203
  }
204
204
  }
205
205
  }
206
206
  },
207
207
  // Chapters
208
- 0x1043a770: {
208
+ 272869232: {
209
209
  name: 'chapters',
210
210
  container: {
211
- 0x45b9: {
211
+ 17849: {
212
212
  name: 'editionEntry',
213
213
  container: {
214
- 0xb6: {
214
+ 182: {
215
215
  name: 'chapterAtom',
216
216
  container: {
217
- 0x73c4: { name: 'uid', value: DataType.uid },
218
- 0x91: { name: 'timeStart', value: DataType.uint },
219
- 0x92: { name: 'timeEnd', value: DataType.uid },
220
- 0x98: { name: 'hidden', value: DataType.bool },
221
- 0x4598: { name: 'enabled', value: DataType.uid },
222
- 0x8f: { name: 'track', container: {
223
- 0x89: { name: 'trackNumber', value: DataType.uid },
224
- 0x80: {
217
+ 29636: { name: 'uid', value: DataType.uid },
218
+ 145: { name: 'timeStart', value: DataType.uint },
219
+ 146: { name: 'timeEnd', value: DataType.uid },
220
+ 152: { name: 'hidden', value: DataType.bool },
221
+ 17816: { name: 'enabled', value: DataType.uid },
222
+ 143: { name: 'track', container: {
223
+ 137: { name: 'trackNumber', value: DataType.uid },
224
+ 128: {
225
225
  name: 'display', container: {
226
- 0x85: { name: 'string', value: DataType.string },
227
- 0x437c: { name: 'language ', value: DataType.string },
228
- 0x437e: { name: 'country ', value: DataType.string }
226
+ 133: { name: 'string', value: DataType.string },
227
+ 17276: { name: 'language ', value: DataType.string },
228
+ 17278: { name: 'country ', value: DataType.string }
229
229
  }
230
230
  }
231
231
  }
@@ -237,34 +237,34 @@ export const elements = {
237
237
  }
238
238
  },
239
239
  // Tagging
240
- 0x1254c367: {
240
+ 307544935: {
241
241
  name: 'tags',
242
242
  container: {
243
- 0x7373: {
243
+ 29555: {
244
244
  name: 'tag',
245
245
  multiple: true,
246
246
  container: {
247
- 0x63c0: {
247
+ 25536: {
248
248
  name: 'target',
249
249
  container: {
250
- 0x63c5: { name: 'tagTrackUID', value: DataType.uid },
251
- 0x63c4: { name: 'tagChapterUID', value: DataType.uint },
252
- 0x63c6: { name: 'tagAttachmentUID', value: DataType.uid },
253
- 0x63ca: { name: 'targetType', value: DataType.string }, // extended
254
- 0x68ca: { name: 'targetTypeValue', value: DataType.uint }, // extended
255
- 0x63c9: { name: 'tagEditionUID', value: DataType.uid } // extended
250
+ 25541: { name: 'tagTrackUID', value: DataType.uid },
251
+ 25540: { name: 'tagChapterUID', value: DataType.uint },
252
+ 25542: { name: 'tagAttachmentUID', value: DataType.uid },
253
+ 25546: { name: 'targetType', value: DataType.string }, // extended
254
+ 26826: { name: 'targetTypeValue', value: DataType.uint }, // extended
255
+ 25545: { name: 'tagEditionUID', value: DataType.uid } // extended
256
256
  }
257
257
  },
258
- 0x67c8: {
258
+ 26568: {
259
259
  name: 'simpleTags',
260
260
  multiple: true,
261
261
  container: {
262
- 0x45a3: { name: 'name', value: DataType.string },
263
- 0x4487: { name: 'string', value: DataType.string },
264
- 0x4485: { name: 'binary', value: DataType.binary },
265
- 0x447a: { name: 'language', value: DataType.string }, // extended
266
- 0x447b: { name: 'languageIETF', value: DataType.string }, // extended
267
- 0x4484: { name: 'default', value: DataType.bool } // extended
262
+ 17827: { name: 'name', value: DataType.string },
263
+ 17543: { name: 'string', value: DataType.string },
264
+ 17541: { name: 'binary', value: DataType.binary },
265
+ 17530: { name: 'language', value: DataType.string }, // extended
266
+ 17531: { name: 'languageIETF', value: DataType.string }, // extended
267
+ 17540: { name: 'default', value: DataType.bool } // extended
268
268
  }
269
269
  }
270
270
  }
@@ -274,3 +274,4 @@ export const elements = {
274
274
  }
275
275
  }
276
276
  };
277
+ //# sourceMappingURL=MatroskaDtd.js.map
@@ -1,8 +1,8 @@
1
- import type { ITokenizer } from 'strtok3';
2
- import { INativeMetadataCollector } from '../common/MetadataCollector.js';
1
+ import { type ITokenizer } from 'strtok3';
2
+ import type { INativeMetadataCollector } from '../common/MetadataCollector.js';
3
3
  import { BasicParser } from '../common/BasicParser.js';
4
- import { IOptions } from '../type.js';
5
- import { ITokenParser } from '../ParserFactory.js';
4
+ import type { IOptions } from '../type.js';
5
+ import type { ITokenParser } from '../ParserFactory.js';
6
6
  /**
7
7
  * Extensible Binary Meta Language (EBML) parser
8
8
  * https://en.wikipedia.org/wiki/Extensible_Binary_Meta_Language
@@ -1,5 +1,6 @@
1
1
  import { Float32_BE, Float64_BE, StringType, UINT8 } from 'token-types';
2
2
  import initDebug from 'debug';
3
+ import { EndOfStreamError } from 'strtok3';
3
4
  import { BasicParser } from '../common/BasicParser.js';
4
5
  import * as matroskaDtd from './MatroskaDtd.js';
5
6
  import { DataType, TargetType, TrackType } from './types.js';
@@ -52,7 +53,7 @@ export class MatroskaParser extends BasicParser {
52
53
  }
53
54
  }
54
55
  const audioTracks = matroska.segment.tracks;
55
- if (audioTracks && audioTracks.entries) {
56
+ if (audioTracks === null || audioTracks === void 0 ? void 0 : audioTracks.entries) {
56
57
  audioTracks.entries.forEach(entry => {
57
58
  const stream = {
58
59
  codecName: entry.codecID.replace('A_', '').replace('V_', ''),
@@ -69,19 +70,14 @@ export class MatroskaParser extends BasicParser {
69
70
  this.metadata.addStreamInfo(stream);
70
71
  });
71
72
  const audioTrack = audioTracks.entries
72
- .filter(entry => {
73
- return entry.trackType === TrackType.audio.valueOf();
74
- })
73
+ .filter(entry => entry.trackType === TrackType.audio)
75
74
  .reduce((acc, cur) => {
76
- if (!acc) {
75
+ if (!acc)
77
76
  return cur;
78
- }
79
- if (!acc.flagDefault && cur.flagDefault) {
77
+ if (cur.flagDefault && !acc.flagDefault)
80
78
  return cur;
81
- }
82
- if (cur.trackNumber && cur.trackNumber < acc.trackNumber) {
79
+ if (cur.trackNumber < acc.trackNumber)
83
80
  return cur;
84
- }
85
81
  return acc;
86
82
  }, null);
87
83
  if (audioTrack) {
@@ -120,7 +116,7 @@ export class MatroskaParser extends BasicParser {
120
116
  element = await this.readElement();
121
117
  }
122
118
  catch (error) {
123
- if (error.message === 'End-Of-Stream') {
119
+ if (error instanceof EndOfStreamError) {
124
120
  break;
125
121
  }
126
122
  throw error;
@@ -141,7 +137,10 @@ export class MatroskaParser extends BasicParser {
141
137
  }
142
138
  }
143
139
  else {
144
- tree[type.name] = await this.parserMap.get(type.value)(element);
140
+ const parser = this.parserMap.get(type.value);
141
+ if (typeof parser === 'function') {
142
+ tree[type.name] = await parser(element);
143
+ }
145
144
  }
146
145
  }
147
146
  else {
@@ -238,3 +237,4 @@ export class MatroskaParser extends BasicParser {
238
237
  }
239
238
  }
240
239
  }
240
+ //# sourceMappingURL=MatroskaParser.js.map
@@ -22,6 +22,7 @@ export interface IContainerType {
22
22
  export interface ITree {
23
23
  [name: string]: string | number | boolean | Uint8Array | ITree | ITree[];
24
24
  }
25
+ export type ValueType = string | number | Uint8Array | boolean | ITree | ITree[];
25
26
  export interface ISeekHead {
26
27
  id?: Uint8Array;
27
28
  position?: number;
@@ -40,9 +41,9 @@ export interface ISegmentInformation {
40
41
  }
41
42
  export interface ITrackEntry {
42
43
  uid?: Uint8Array;
43
- trackNumber?: number;
44
+ trackNumber: number;
44
45
  trackType?: TrackType;
45
- audio?: ITrackAudio;
46
+ audio: ITrackAudio;
46
47
  video?: ITrackVideo;
47
48
  flagEnabled?: boolean;
48
49
  flagDefault?: boolean;
@@ -51,7 +52,7 @@ export interface ITrackEntry {
51
52
  trackTimecodeScale?: number;
52
53
  name?: string;
53
54
  language?: string;
54
- codecID?: string;
55
+ codecID: string;
55
56
  codecPrivate?: Uint8Array;
56
57
  codecName?: string;
57
58
  codecSettings?: string;
@@ -121,6 +122,7 @@ export declare enum TrackType {
121
122
  button = 18,
122
123
  control = 32
123
124
  }
125
+ export type TrackTypeKey = keyof TrackType;
124
126
  export interface ITarget {
125
127
  trackUID?: Uint8Array;
126
128
  chapterUID?: Uint8Array;
@@ -146,7 +148,7 @@ export interface IAttachmedFile {
146
148
  uid: string;
147
149
  }
148
150
  export interface IAttachments {
149
- attachedFiles?: IAttachmedFile[];
151
+ attachedFiles: IAttachmedFile[];
150
152
  }
151
153
  export interface IMatroskaSegment {
152
154
  metaSeekInfo?: IMetaSeekInformation;
package/lib/mp4/Atom.d.ts CHANGED
@@ -4,11 +4,11 @@ export type AtomDataHandler = (atom: Atom, remaining: number) => Promise<void>;
4
4
  export declare class Atom {
5
5
  readonly header: AtomToken.IAtomHeader;
6
6
  extended: boolean;
7
- readonly parent: Atom;
8
- static readAtom(tokenizer: ITokenizer, dataHandler: AtomDataHandler, parent: Atom, remaining: number): Promise<Atom>;
7
+ readonly parent: Atom | null;
8
+ static readAtom(tokenizer: ITokenizer, dataHandler: AtomDataHandler, parent: Atom | null, remaining: number): Promise<Atom>;
9
9
  readonly children: Atom[];
10
10
  readonly atomPath: string;
11
- constructor(header: AtomToken.IAtomHeader, extended: boolean, parent: Atom);
11
+ constructor(header: AtomToken.IAtomHeader, extended: boolean, parent: Atom | null);
12
12
  getHeaderLength(): number;
13
13
  getPayloadLength(remaining: number): number;
14
14
  readAtoms(tokenizer: ITokenizer, dataHandler: AtomDataHandler, size: number): Promise<void>;