The purpose of this library is to be very fast and small. It’s suitable for server-side or client-side. Really any platform that supports ArrayBuffer
and its ilk (Uint8Array
, etc.).
I wrote it because the other libraries were large and very robust; I just needed something that could extract the metadata out without requiring 30KB of JavaScript. audio-metadata.min.js
comes in at 6.1K/2.1K minified/gzipped.
To accomplish the small size and speed, it sacrifices several things.
As such, the code is a bit abstruse, in that you’ll see some magic numbers, like offset += 94
where it’s ignoring a bunch of header data to get to the good stuff.
Don’t judge me based on this code. It works and it’s tested; it’s just hard to read.
Of course, since this isn’t an actual parser, invalid files will also work.
This means, for example, you could only read the first couple hundred bytes of an MP3 file and still extract the metadata from it, rather than requiring actual valid MP3 data.
The library operates solely on ArrayBuffer
s, or Buffer
s for Node’s convenience. So you’ll need to preload your audio data before using this library.
The library defines three methods:
// extract comments from OGG container
AudioMetaData.ogg(buffer)
// extract ID3v2 tags
AudioMetaData.id3v2(buffer);
// extract ID3v1 tags
AudioMetaData.id3v1(buffer);
The result is an object with the metadata. It attempts to normalize common keys:
TIT1
and TIT2
in id3v2)TSE1
in id3v2)TCOM
in id3v2)TALB
in id3v2)TRCK
in id3v2, commonly TRACKNUMBER
in vorbis comments)TDRC
(date recorded) is used in id3v2)TSSE
in id3v2)TCON
in id3v2)Everything else will be keyed by its original name. For id3v2, anything that is not a text identifier (i.e. a frame that starts with a “T”) is ignored. This includes comments (COMM
).
Install it using NPM: npm install audio-metadata
or npm install -g audio-metadata
if you want to use it from the shell.
var audioMetaData = require('audio-metadata'),
fs = require('fs');
var oggData = fs.readFileSync('/path/to/my.ogg');
var metadata = audioMetaData.ogg(oggData);
/*
{
"title": "Contra Base Snippet",
"artist": "Konami",
"album": "Bill and Lance's Excellent Adventure",
"year": "1988",
"tracknumber": "1",
"track": "1",
"encoder": "Lavf53.21.1"
}
*/
For more information click here.
Kali Linux 2024.4, the final release of 2024, brings a wide range of updates and…
This Go program applies a lifetime patch to PowerShell to disable ETW (Event Tracing for…
GPOHunter is a comprehensive tool designed to analyze and identify security misconfigurations in Active Directory…
Across small-to-medium enterprises (SMEs) and managed service providers (MSPs), the top priority for cybersecurity leaders…
The free and open-source security platform SecHub, provides a central API to test software with…
Don't worry if there are any bugs in the tool, we will try to fix…