Launch Week Day 3: Introducing Organization Notifications in Socket.Learn More
Socket
Book a DemoSign in
Socket

mp4-tag

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mp4-tag

MP4 metadata tagging library written in pure JavaScript

latest
Source
npmnpm
Version
0.1.0-beta
Version published
Maintainers
0
Created
Source

Node.js CI npm Maintenance

mp4-tag is an open sourced JavaScript library used to view and edit the metadata of MP4 media files.

You can explore the examples directory to show how to use the library.

Features

  • Read and write MP4 metadata
  • Easy to use

Installation

You can download the ready-to-use script at GitHub releases or you can build your own by cloning this repository using git then build it.

git clone https://github.com/eidoriantan/mp4-tag
cd ./mp4-tag
npm install
npm run build

You can also install this package by using npm:

npm install --save mp4-tag@latest

If you are using browser, you can just install the library through a CDN:

<script src="https://cdn.jsdelivr.net/npm/mp4-tag@latest/dist/mp4-tag.min.js">

Usage

For browsers:

<input type="file" id="input-file" accept="video/mp4">
<script>
const inputFile = document.getElementById('input-file')
inputFile.onchange = function () {
  const reader = new FileReader()
  reader.onload = function () {
    const buffer = this.result

    const mp4tag = new MP4Tag(buffer)
    mp4tag.read()

    // Handle error if there's any
    if (mp4tag.error !== '') throw new Error(mp4tag.error)
    else console.log(mp4tag.metadata)
  }

  if (this.files.length > 0) {
    reader.readAsArrayBuffer(this.files[0])
  }
}
</script>

For Node.js:

const MP4Tag = require('mp4-tag')
const fs = require('fs')

const buffer = fs.readFileSync('/path/to/video.mp4')
const mp4tag = new MP4Tag(buffer)

mp4tag.read()

// Handle error if there's any
if (mp4tag.error !== '') throw new Error(mp4tag.error)
else console.log(mp4tag.tags)

Support

If you had found a bug or any unexpected behavior, you can submit an issue through GitHub issues.

Keywords

node

FAQs

Package last updated on 11 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts