GithubHelp home page GithubHelp logo

ondras / musicmetadata Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leetreveil/musicmetadata

0.0 2.0 0.0 59.89 MB

Streaming music metadata parser for node and the browser.

JavaScript 99.54% HTML 0.46%

musicmetadata's Introduction

Build Status NPM version npm downloads

Streaming music metadata parser for node and the browser.

Installation

Install via npm:

npm install musicmetadata

You can also download a pre packaged browser release from dist/musicmetadata.js. See example/index.html for usage.

Supports

  • mp3 (1.1, 2.2, 2.3, 2.4)
  • m4a (mp4)
  • vorbis (ogg, flac)
  • asf (wma, wmv)

API

var fs = require('fs');
var mm = require('musicmetadata');

// create a new parser from a node ReadStream
var parser = mm(fs.createReadStream('sample.mp3'), function (err, metadata) {
  if (err) throw err;
  console.log(metadata);
});

This will output the standard music metadata:

{ artist : ['Spor'],
  album : 'Nightlife, Vol 5.',
  albumartist : [ 'Andy C', 'Spor' ],
  title : 'Stronger',
  year : '2010',
  track : { no : 1, of : 44 },
  disk : { no : 1, of : 2 },
  genre : ['Drum & Bass'],
  picture : [ { format : 'jpg', data : <Buffer> } ],
  duration : 302.41 // in seconds
}

musicmetadata also emits all metadata it discovers during parsing. For example if you wanted to read the TLEN frame from an id3v2.x file you can do this:

parser.on('TLEN', function (result) {
  console.log(result);
});

You can also read the duration; to calculate the duration musicmetadata may need to parse the entire file so only enable this if you need the functionality.

var parser = mm(fs.createReadStream('sample.mp3'), { duration: true }, function (err, metadata) {
  
});

Note that in order to read the duration for streams that are not file streams, you must also pass the size of the file in bytes.

var parser = mm(fs.createReadStream('sample.mp3'), { duration: true, fileSize: 26838 }, function (err, metadata) {
  
});

Licence

(The MIT License)

Copyright (c) 2015 Lee Treveil [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

musicmetadata's People

Contributors

leetreveil avatar andrewrk avatar tim-smart avatar pmarques avatar jpage-godaddy avatar dertseha avatar benkaiser avatar danielearwicker avatar bahamas10 avatar mutewinter avatar cobalamin avatar

Watchers

Ondřej Žára 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.