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

mp4-metadata

v1.0.2

Published

Fast mp4 moov metadata parsing via optimized file streaming

Downloads

193

Readme

mp4-parser

mp4-parser is a client side javascript library that will parse the creation time of a mp4 video.

License: MIT

Example

const mp4Metadata = require('mp4-metadata').default;

...

const mp4File = retrieveMp4File();
const creationTime = await mp4Metadata.getCreationTime(mp4File);
// 2016-06-03T20:51:02.000Z

Usage

npm install mp4-metadata

See it out on npm here

Installation - local development or to build it yourself.

Clone

Clone https://github.com/nadr0/mp4-metadata to your machine

Setup

We need to install all the dev dependencies for you to compile the source code into the distribution source.

npm install

Build

To build the source code to ES5 run the following.

npm run build

Usage

Building the repository should create distribution/index.js. This index.js file is all the source code of the library. Import it into whatever application you want.

Code Structure

All the source for the library is in source/index.js. It is written in modern ES6+.

If you want to use the ES6+ source feel free to grab that file directly as well. If you do not have support for ES6+ please use the build command above to generate an ES5 distribution source.

Features

I hope I update this library to parse all the metadata out of the moov atom inside an mp4 file. The only feature it supports now is getting the creation time of an mp4 file.

Documentation

The only exposed function right now is called getCreationTime

/**
 * Retrieves the creation time of the mp4 video
 * @param {(File | Blob)} file 
 * @param options configuration options for the parser
 * @param options.defaultChunkSize the default chunk size to parse per iteration in bytes
 * @param options.maxBytesRead the amount of bytes the parser will read before stopping. Make this the file size to read the entire file.
 * @return {(String | null)} a date time iso string of the creation time or null
 */
const getCreationTime = async (file, options={}) => 
  • Quickly read the metadata from the back without searching the whole file
const mp4Metadata = require('mp4-metadata').default;

const mp4File = retrieveMp4File();
const creationTime = await mp4Metadata.getCreationTime(mp4File);
// 2016-06-03T20:51:02.000Z
  • To read the entire file for the metadata
const mp4Metadata = require('mp4-metadata').default;

const mp4File = retrieveMp4File();
const options = {maxBytesRead: mp4File.size};
const creationTime = await mp4Metadata.getCreationTime(mp4File, options);
// 2016-06-03T20:51:02.000Z

Contributing

Feel free, make some issues make some PRs.

FAQ

  • Why only this one function?
    • So far this was the only problem I needed to solve. I want to expand this further to parse out the rest of the metadata the same way.

Support

Reach out to me at one of the following places

  • Website at kevinnadro.com

License

License: MIT