Git Product home page Git Product logo

mp3-parser's Introduction

mp3 Parser

Build Status NPM version

Locate and read mp3 sections: Individual mp3 frames as well as ID3v2 and Xing/Lame tags. For each of these sections present within a given mp3 file, mp3 Parser will provide data indicating their presence, their boundaries within the file, as well as any available informative data. In the current implementation, the latter is strictly true only for frames as thorough parsing and data-extraction from ID3v2 and Xing/Lame tags is work in progress. The primary use case (and raison d'etre) for this initial revision is performing precise cuts at frame / tag boundaries.

Set up

mp3 Parser may be used as a CommonJS module on Node or in a browser, either through a plain <script> tag or as an AMD module. It will be automatically exported in the correct format depending on the detected environment. To get it, git clone git://github.com/biril/mp3-parser or npm install mp3-parser.

  • When working in a browser, without an AMD module loader, include mp3-parser.js:

    ...
    <script type="text/javascript" src="mp3-parser.js"></script>
    ...

    and the module will be exposed as the global mp3Parser:

    console.log("mp3 Parser version: " + mp3Parser.version);
  • require when working with CommonJS (e.g. Node). Assuming mp3 Parser is npm installed:

    var mp3Parser = require("mp3-parser");
    console.log("mp3 Parser version: " + mp3Parser.version);
  • Or list as a dependency when working with an AMD loader (e.g. require.js):

    // Your module
    define(["mp3-parser"], function (mp3Parser) {
    	console.log("mp3 Parser version: " + mp3Parser.version);
    });

Usage

The parser exposes a collection of read____ methods, each dedicated to reading a specific section of the mp3 file. The current implementation includes readFrameHeader, readFrame, readId3v2Tag and readXingTag. Each of these accepts a DataView-wrapped ArrayBuffer, which should contain the actual mp3 data, and optionally an offset into the buffer.

All methods return a description of the section read in the form of a hash containing key-value pairs relevant to the section. For example the hash returned by readFrameHeader always contains an mpegAudioVersion key of value "MPEG Version 1 (ISO/IEC 11172-3)" and a layerDescription key of value "Layer III". A description will always have a _section hash with type, byteLength and offset keys:

  • type: "frame", "frameHeader", "Xing" or "ID3v2"
  • byteLenfth: Size of the section in bytes
  • offset: Buffer offset at which this section resides

Further documentation is forthcoming. You can also

  • View the annotated version of the source.
  • Try the example script example/parse.js. Run it with node parse.js <mp3-file>

License

Licensed and freely distributed under the MIT License (LICENSE.txt).

Copyright (c) 2013 Alex Lambiris

mp3-parser's People

Contributors

biril avatar

Watchers

Moritz Johner avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.