Skip to content

chrisguttandin/metadata-detector

Repository files navigation

metadata-detector

A tool to locate and strip metadata from files.

version

This package is currently capable of handling ID3 tags within MP3s and metadata of FLAC files as described in the official FLAC format specification. It can also parse Vorbis Comments within OGG Containers. In addition to that it can also parse MPEG-4 files which are nicely explained on the homepage of AtomicParsley.

Usage

This package is intended to be used in the browser. Please take a look at metadata-detector-streams if you look for a package that works with Node.js.

metadata-detector is available as a package on npm. You can use the following command to install it:

npm install metadata-detector

The package exports two functions to locate and to strip metadata from a given ArrayBuffer.

locate(arrayBuffer)

locate(arrayBuffer: ArrayBuffer) => Promise<[number, number][]>;

locate() can be used to find metadata within a given ArrayBuffer. It will return an array of tuples. Each tuple consists of two numbers. Those numbers are byte offsets. The first number is the start of the metadata and the second number marks the end.

import { locate } from 'metadata-detector';

const detectedLocations = await locate(arrayBuffer);
// [
//     [28, 36],
//     [1290, 2124]
//  ]

strip(arrayBuffer)

strip(arrayBuffer: ArrayBuffer) => Promise<ArrayBuffer>;

strip() can be used to remove the metadata from a given ArrayBuffer. It will return a new ArrayBuffer without all the detected metadata.

import { strip } from 'metadata-detector';

const strippedArrayBuffer = await strip(arrayBuffer);
// ArrayBuffer