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!
Here the MP4 is being requested by partial AJAX requests, such that only the metatags are read rather than the file as a whole.
First, install mp4.js using NPM, the Node package manager.
npm install mp4js
Then use it like so:
var mp4 = ;;
Note that here, the type is set to 'local' directly so that mp4.js will attempt to read from the local file-system using
This will only work under NodeJS.
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.
Tags are passed as an object of the following format:
year properties will always exist, though they will default to null.
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)
As you can see, the data is provided as an
ArrayBuffer. To access it, you may use a
DataView or typed array such as