MCPcopy Index your code
hub / github.com/Borewit/music-metadata

github.com/Borewit/music-metadata @v11.13.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v11.13.0 ↗ · + Follow
842 symbols 1,769 edges 156 files 71 documented · 8% 16 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

CI NPM version npm downloads Coverage Status Codacy Badge CodeQL DeepScan grade Known Vulnerabilities

music-metadata

logo

Key features: - Comprehensive Format Support: Supports popular audio formats like MP3, MP4, FLAC, Ogg, WAV, AIFF, and more. - Extensive Metadata Extraction: Extracts detailed metadata, including ID3v1, ID3v2, APE, Vorbis, and iTunes/MP4 tags. - Streaming Support: Efficiently handles large audio files by reading metadata from streams, making it suitable for server-side and browser-based applications. - Promise-Based API: Provides a modern, promise-based API for easy integration into asynchronous workflows. - Cross-Platform: Works in both Node.js and browser environments with the help of bundlers like Webpack or Rollup.

The music-metadata module is ideal for developers working on media applications, music players, or any project that requires access to detailed audio file metadata.

Compatibility

Module: version 8 migrated from CommonJS to pure ECMAScript Module (ESM). The distributed JavaScript codebase is compliant with the ECMAScript 2020 (11th Edition) standard.

[!NOTE] See also CommonJS backward Compatibility

This module requires a Node.js ≥ 18 engine. It can also be used in a browser environment when bundled with a module bundler.

Support the Project

If you find this project useful and would like to support its development, consider sponsoring or contributing:

Buy me A coffee

Features

Support for audio file types

Audio format Description Logo
AIFF / AIFF-C Audio Interchange File Format Apple rainbow logo
AAC ADTS / Advanced Audio Coding AAC logo
APE Monkey's Audio Monkey's Audio logo
ASF Advanced Systems Format
BWF Extended WAV format for broadcast and archiving
DSDIFF Philips DSDIFF DSD logo
DSF Sony's DSD Stream File DSD logo
FLAC Free Lossless Audio Codec FLAC logo
MP2 MPEG-1 Audio Layer II (predecessor to MP3)
Matroska Matroska (EBML), mka, mkv Matroska logo
MP3 MPEG-1 / MPEG-2 Audio Layer III MP3 logo
MPC Musepack SV7 musepack logo
MPEG 4 mp4, m4a, m4v mpeg 4 logo
Ogg Open container format Ogg logo
Opus Low-latency, high-quality codec for speech and music Opus logo
Speex Open-source speech codec optimized for VoIP Speex logo
Theora Open video compression format (typically paired with Ogg) Theora logo
Vorbis Vorbis audio compression Vorbis logo
WAV Uncompressed PCM audio in RIFF container
WebM WebM Matroska logo
WV WavPack WavPack logo
WMA Windows Media Audio Windows Media logo

Supported tag headers

Following tag header formats are supported: - APE - ASF - EXIF 2.3 - ID3: ID3v1, ID3v1.1, ID3v2.2, ID3v2.3, ID3v2.4 and ID3v2 Chapters 1.0 - iTunes - RIFF/INFO - Vorbis comment - AIFF

Following lyric formats are supported: - LRC - Synchronized lyrics (SYLT) - Unsynchronized lyrics (USULT)

Support for MusicBrainz tags as written by Picard. ReplayGain tags are supported.

Audio format & encoding details

Support for encoding / format details: - Bit rate - Audio bit depth - Duration - Encoding profile (e.g. CBR, V0, V2)

Online demo's

Usage

Installation

Install using npm:

npm install music-metadata

or using yarn:

yarn add music-metadata

API Documentation

Overview

Node.js specific functions to read an audio file or stream: 1. File Parsing: Parse audio files directly from the filesystem using the parseFile function 1. Stream Parsing: Parse audio metadata from a Node.js Readable stream using the parseStream function.

Cross-platform functions available to read an audio file or stream:

There are multiple ways to parse (read) audio tracks: 1. Web Stream Parsing: Parse audio data from a web-compatible ReadableStream using the parseWebStream function. 1. Blob Parsing: Parse audio metadata from a (Web API) Blob or File using the parseBlob function. 1. Buffer Parsing: Parse audio metadata from a Uint8Array or Buffer using the parseBuffer function. 1. Tokenizer Parsing: Use a custom or third-party strtok3 ITokenizer to parse using the parseFromTokenizer function.

[!NOTE] Direct file access in Node.js is generally faster because it can 'jump' to various parts of the file without reading intermediate data.

Node.js specific function

These functions are tailored for Node.js environments and leverage Node.js-specific APIs, making them incompatible with browser-based JavaScript engines.

parseFile function

The parseFile function is intended for extracting metadata from audio files on the local filesystem in a Node.js environment. It reads the specified file, parses its audio metadata, and returns a promise that resolves with this information.

Syntax
parseFile(filePath: string, options?: IOptions): Promise<IAudioMetadata>
Parameters
  • filePath: string

The path to the media file from which metadata should be extracted. This should be a valid path to an audio file on the local filesystem.

An optional configuration object that allows customization of the parsing process. These options can include whether to calculate the file's duration, skip embedded cover art, or other parsing behaviors.

Returns
  • `Promise<IAudioM

Extension points exported contracts — how you extend this code

ITokenParser (Interface)
(no doc) [14 implementers]
lib/ParserFactory.ts
IPageConsumer (Interface)
(no doc) [4 implementers]
lib/ogg/OggToken.ts
ICodecListObjectHeader (Interface)
* 3.5: The Codec-List-Object interface.
lib/asf/AsfObject.ts
IWarningCollector (Interface)
(no doc) [2 implementers]
lib/common/MetadataCollector.ts
IAtomStsdHeader (Interface)
* Atom: Sample Description Atom ('stsd')
lib/mp4/AtomToken.ts
IStreamHeader1 (Interface)
* Stream Header Packet * Ref: http://trac.musepack.net/musepack/wiki/SV8Specification#StreamHeaderPacket
lib/musepack/sv8/StreamVersion8.ts
IId3v1Header (Interface)
* ID3v1 tag header interface
lib/id3v1/ID3v1Parser.ts
ITagInfoDict (Interface)
(no doc)
doc-gen/gen.ts

Core symbols most depended-on inside this repo

setFormat
called by 150
lib/common/MetadataCollector.ts
get
called by 134
lib/mp4/AtomToken.ts
ignore
called by 56
lib/musepack/sv7/BitReader.ts
parse
called by 55
lib/ParserFactory.ts
get
called by 52
lib/wav/WaveChunk.ts
get
called by 43
lib/id3v1/ID3v1Parser.ts
get
called by 32
lib/ogg/opus/Opus.ts
get
called by 27
lib/aiff/AiffToken.ts

Shape

Method 309
Class 218
Function 159
Interface 156

Languages

TypeScript100%

Modules by API surface

lib/mp4/AtomToken.ts96 symbols
lib/asf/AsfObject.ts51 symbols
lib/mpeg/MpegParser.ts28 symbols
lib/type.ts25 symbols
lib/common/MetadataCollector.ts25 symbols
lib/id3v2/FrameParser.ts24 symbols
lib/mp4/MP4Parser.ts23 symbols
lib/ParseError.ts20 symbols
lib/ebml/EbmlIterator.ts19 symbols
lib/matroska/types.ts18 symbols
lib/id3v2/ID3v2Parser.ts16 symbols
lib/ParserFactory.ts15 symbols

For agents

$ claude mcp add music-metadata \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page