npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mp4js

v0.0.2

Published

A modern MP4 parser written completely in JavaScript, making use of typed arrays and the HTML5 File API

Downloads

11

Readme

mp4.js - Javascript MP4 tag parser

mp4.js is a JavaScript library for reading and parsing metatags of MP4 files (m4a,m4v,ALAC). mp4.js can parse metadata within a browser or Node environment. It also supports reading from local files (Node-only), same-origin URLs (AJAX) and File instances (HTML5 File API).

Compatibility for AJAX/FileReaderAPI and nodejs is taken from [https://github.com/43081j/id3](43081j's ID3.js), implementation details are based upon the magnificent taglib, thanks for that!

AJAX

<script src="mp4.min.js"></script>
<script type="text/javascript">
mp4('/audio/track.m4a', function(err, tags) {
	// tags now contains tags
});
</script>

Here the MP4 is being requested by partial AJAX requests, such that only the metatags are read rather than the file as a whole.

Local Files

First, install mp4.js using NPM, the Node package manager.

npm install mp4js

Then use it like so:

var mp4 = require('mp4js');

mp4({ file: './track.m4a', type: 'local' }, function(err, tags) {
	// tags now contains your MP4 tags
});

Note that here, the type is set to 'local' directly so that mp4.js will attempt to read from the local file-system using fs.

This will only work under NodeJS.

File API (HTML5)

<script src="mp4.min.js"></script>
<script type="text/javascript">
document.querySelector('input[type="file"]').onchange = function(e) {
	mp4(this.files[0], function(err, tags) {
		// tags now contains your MP4 tags
	});
}
</script>

This will read the data from the File instance using slices, so the entire file is not loaded into memory but rather only the tags.

Format

Tags are passed as an object of the following format:

{
	"artist": "Song artist",
	"title": "Song name",
	"album": "Song album",
	"year": "2013",
	"date": "2013-01-10T20:20:10Z",
	"tracknumber": [2, 18]
	"track": "2/18"
}

The artist, title, album and year properties will always exist, though they will default to null.

Images

On occasion, an MP4 may have an image embedded in the metatag. If this is the case, it will be available through cover. This has a structure like so:

FIXME (the API does not pass the MP4 cover through yet, but parsing of covers is ready)

{
	"type": "cover-front",
	"mime": "image/jpeg",
	"description": null,
	"data": ArrayBuffer
}

As you can see, the data is provided as an ArrayBuffer. To access it, you may use a DataView or typed array such as Uint8Array.

License

MIT