music-metadata 8.1.1 → 8.1.3

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 CHANGED
@@ -4,8 +4,7 @@
4
4
  [![npm downloads](http://img.shields.io/npm/dm/music-metadata.svg)](https://npmcharts.com/compare/music-metadata,jsmediatags,musicmetadata,node-id3,mp3-parser,id3-parser,wav-file-info?start=600)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/Borewit/music-metadata/badge.svg?branch=master)](https://coveralls.io/github/Borewit/music-metadata?branch=master)
6
6
  [![Codacy Badge](https://api.codacy.com/project/badge/Grade/57d731b05c9e41889a2a17cb4b0384d7)](https://app.codacy.com/app/Borewit/music-metadata?utm_source=github.com&utm_medium=referral&utm_content=Borewit/music-metadata&utm_campaign=Badge_Grade_Dashboard)
7
- [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Borewit/music-metadata.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Borewit/music-metadata/context:javascript)
8
- [![Total alerts](https://img.shields.io/lgtm/alerts/g/Borewit/music-metadata.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Borewit/music-metadata/alerts/)
7
+ [![CodeQL](https://github.com/Borewit/music-metadata/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/Borewit/music-metadata/actions/workflows/codeql-analysis.yml)
9
8
  [![DeepScan grade](https://deepscan.io/api/teams/5165/projects/6938/branches/61821/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=5165&pid=6938&bid=61821)
10
9
  [![Known Vulnerabilities](https://snyk.io/test/github/Borewit/music-metadata/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Borewit/music-metadata?targetFile=package.json)
11
10
  [![Discord](https://img.shields.io/discord/460524735235883049.svg)](https://discord.gg/KyBr6sb)
package/lib/mp4/Atom.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import initDebug from 'debug';
2
2
  import * as AtomToken from './AtomToken.js';
3
+ import { Header } from './AtomToken.js';
3
4
  const debug = initDebug('music-metadata:parser:MP4:Atom');
4
5
  export class Atom {
5
6
  static async readAtom(tokenizer, dataHandler, parent, remaining) {
@@ -52,8 +53,10 @@ export class Atom {
52
53
  return this.readAtoms(tokenizer, dataHandler, this.getPayloadLength(remaining));
53
54
  case 'meta': // Metadata Atom, ref: https://developer.apple.com/library/content/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW8
54
55
  // meta has 4 bytes of padding, ignore
55
- await tokenizer.ignore(4);
56
- return this.readAtoms(tokenizer, dataHandler, this.getPayloadLength(remaining) - 4);
56
+ const peekHeader = await tokenizer.peekToken(Header);
57
+ const paddingLength = peekHeader.name === 'hdlr' ? 0 : 4;
58
+ await tokenizer.ignore(paddingLength);
59
+ return this.readAtoms(tokenizer, dataHandler, this.getPayloadLength(remaining) - paddingLength);
57
60
  case 'mdhd': // Media header atom
58
61
  case 'mvhd': // 'movie' => 'mvhd': movie header atom; child of Movie Atom
59
62
  case 'tkhd':
@@ -96,7 +96,12 @@ export class WaveParser extends BasicParser {
96
96
  this.metadata.setFormat('numberOfSamples', numberOfSamples);
97
97
  this.metadata.setFormat('duration', numberOfSamples / this.metadata.format.sampleRate);
98
98
  }
99
- this.metadata.setFormat('bitrate', this.metadata.format.numberOfChannels * this.blockAlign * this.metadata.format.sampleRate); // ToDo: check me
99
+ if (this.metadata.format.codec === 'ADPCM') { // ADPCM is 4 bits lossy encoding resulting in 352kbps
100
+ this.metadata.setFormat('bitrate', 352000);
101
+ }
102
+ else {
103
+ this.metadata.setFormat('bitrate', this.blockAlign * this.metadata.format.sampleRate * 8);
104
+ }
100
105
  await this.tokenizer.ignore(header.chunkSize);
101
106
  break;
102
107
  case 'bext': // Broadcast Audio Extension chunk https://tech.ebu.ch/docs/tech/tech3285.pdf
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": "8.1.1",
4
+ "version": "8.1.3",
5
5
  "author": {
6
6
  "name": "Borewit",
7
7
  "url": "https://github.com/Borewit"
@@ -105,7 +105,7 @@
105
105
  "@types/mocha": "^10.0.0",
106
106
  "@types/node": "^18.11.18",
107
107
  "@typescript-eslint/eslint-plugin": "^5.48.0",
108
- "@typescript-eslint/parser": "^5.48.0",
108
+ "@typescript-eslint/parser": "^5.48.1",
109
109
  "c8": "^7.12.0",
110
110
  "chai": "^4.3.7",
111
111
  "chai-as-promised": "^7.1.1",
@@ -120,7 +120,7 @@
120
120
  "mime": "^3.0.0",
121
121
  "mocha": "^10.1.0",
122
122
  "npm-run-all": "^4.1.5",
123
- "prettier": "^2.8.1",
123
+ "prettier": "^2.8.2",
124
124
  "remark-cli": "^11.0.0",
125
125
  "remark-preset-lint-recommended": "^6.1.2",
126
126
  "ts-node": "^10.9.1",