music-metadata 10.7.0 → 10.7.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.
@@ -291,7 +291,7 @@ interface IAtomStsdHeader extends IVersionAndFlags {
291
291
  export interface ISampleDescription {
292
292
  dataFormat: string;
293
293
  dataReferenceIndex: number;
294
- description: Uint8Array;
294
+ description: Uint8Array | undefined;
295
295
  }
296
296
  export interface IAtomStsd {
297
297
  header: IAtomStsdHeader;
@@ -214,17 +214,18 @@ const stsdHeader = {
214
214
  };
215
215
  /**
216
216
  * Atom: Sample Description Atom ('stsd')
217
- * Ref: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-25691
217
+ * Ref: https://developer.apple.com/documentation/quicktime-file-format/sample_description_atom
218
218
  */
219
219
  class SampleDescriptionTable {
220
220
  constructor(len) {
221
221
  this.len = len;
222
222
  }
223
223
  get(buf, off) {
224
+ const descrLen = this.len - 12;
224
225
  return {
225
226
  dataFormat: FourCcToken.get(buf, off),
226
227
  dataReferenceIndex: Token.UINT16_BE.get(buf, off + 10),
227
- description: new Token.Uint8ArrayType(this.len - 12).get(buf, off + 12)
228
+ description: descrLen > 0 ? new Token.Uint8ArrayType(descrLen).get(buf, off + 12) : undefined
228
229
  };
229
230
  }
230
231
  }
@@ -243,7 +244,7 @@ export class StsdAtom {
243
244
  for (let n = 0; n < header.numberOfEntries; ++n) {
244
245
  const size = Token.UINT32_BE.get(buf, off); // Sample description size
245
246
  off += Token.UINT32_BE.len;
246
- table.push(new SampleDescriptionTable(size).get(buf, off));
247
+ table.push(new SampleDescriptionTable(size - Token.UINT32_BE.len).get(buf, off));
247
248
  off += size;
248
249
  }
249
250
  return {
@@ -4,9 +4,9 @@ import { BasicParser } from '../common/BasicParser.js';
4
4
  import { Genres } from '../id3v1/ID3v1Parser.js';
5
5
  import { Atom } from './Atom.js';
6
6
  import * as AtomToken from './AtomToken.js';
7
+ import { Mp4ContentError } from './AtomToken.js';
7
8
  import { TrackType } from '../type.js';
8
9
  import { uint8ArrayToHex, uint8ArrayToString } from 'uint8array-extras';
9
- import { Mp4ContentError } from './AtomToken.js';
10
10
  const debug = initDebug('music-metadata:parser:MP4');
11
11
  const tagFormat = 'iTunes';
12
12
  const encoderDict = {
@@ -442,14 +442,16 @@ export class MP4Parser extends BasicParser {
442
442
  dataReferenceIndex: sampleDescription.dataReferenceIndex
443
443
  };
444
444
  let offset = 0;
445
- const version = AtomToken.SoundSampleDescriptionVersion.get(sampleDescription.description, offset);
446
- offset += AtomToken.SoundSampleDescriptionVersion.len;
447
- if (version.version === 0 || version.version === 1) {
448
- // Sound Sample Description (Version 0)
449
- ssd.description = AtomToken.SoundSampleDescriptionV0.get(sampleDescription.description, offset);
450
- }
451
- else {
452
- debug(`Warning: sound-sample-description ${version} not implemented`);
445
+ if (sampleDescription.description) {
446
+ const version = AtomToken.SoundSampleDescriptionVersion.get(sampleDescription.description, offset);
447
+ offset += AtomToken.SoundSampleDescriptionVersion.len;
448
+ if (version.version === 0 || version.version === 1) {
449
+ // Sound Sample Description (Version 0)
450
+ ssd.description = AtomToken.SoundSampleDescriptionV0.get(sampleDescription.description, offset);
451
+ }
452
+ else {
453
+ debug(`Warning: sound-sample-description ${version} not implemented`);
454
+ }
453
455
  }
454
456
  return ssd;
455
457
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "music-metadata",
3
3
  "description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
4
- "version": "10.7.0",
4
+ "version": "10.7.1",
5
5
  "author": {
6
6
  "name": "Borewit",
7
7
  "url": "https://github.com/Borewit"
@@ -90,11 +90,11 @@
90
90
  "lyrics"
91
91
  ],
92
92
  "scripts": {
93
- "clean": "del-cli 'lib/**/*.js' 'lib/**/*.js.map' 'lib/**/*.d.ts' 'src/**/*.d.ts' 'test/**/*.js' 'test/**/*.js.map' 'test/**/*.js' 'test/**/*.js.map' 'doc-gen/**/*.js' 'doc-gen/**/*.js.map'",
93
+ "clean": "del-cli 'lib/**/*.js' 'lib/**/*.js.map' 'lib/**/*.d.ts' 'test/**/*.js' 'test/**/*.js.map' 'test/**/*.js' 'test/**/*.js.map' 'doc-gen/**/*.js' 'doc-gen/**/*.js.map'",
94
94
  "compile-src": "tsc -p lib",
95
95
  "compile-test": "tsc -p test",
96
96
  "compile-doc": "tsc -p doc-gen",
97
- "compile": "yarn run compile-src && yarn compile-test && yarn compile-doc",
97
+ "compile": "yarn run compile-src && yarn compile-test && yarn compile-doc",
98
98
  "lint-ts": "biome check",
99
99
  "lint-md": "yarn run remark -u remark-preset-lint-consistent .",
100
100
  "lint": "yarn run lint-ts && yarn run lint-md",
@@ -123,7 +123,7 @@
123
123
  "@types/debug": "^4.1.12",
124
124
  "@types/media-typer": "^1.1.3",
125
125
  "@types/mocha": "^10.0.10",
126
- "@types/node": "^22.10.5",
126
+ "@types/node": "^22.10.7",
127
127
  "c8": "^10.1.3",
128
128
  "chai": "^5.1.2",
129
129
  "chai-as-promised": "^8.0.1",
@@ -146,5 +146,5 @@
146
146
  "bugs": {
147
147
  "url": "https://github.com/Borewit/music-metadata/issues"
148
148
  },
149
- "packageManager": "yarn@4.3.1"
149
+ "packageManager": "yarn@4.6.0"
150
150
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};