All Projects → buzz → Mediainfo.js

buzz / Mediainfo.js

Licence: bsd-2-clause
MediaInfo ported to the web using emscripten

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Mediainfo.js

Sickchill
Less rage, more chill.
Stars: ✭ 2,166 (+898.16%)
Mutual labels:  media
Vue Media
A CSS media query component for Vue.js
Stars: ✭ 189 (-12.9%)
Mutual labels:  media
Jcplayer
🎵 A simple audio player for Android applications.
Stars: ✭ 209 (-3.69%)
Mutual labels:  media
Magnum Examples
Examples for the Magnum C++11/C++14 graphics engine
Stars: ✭ 180 (-17.05%)
Mutual labels:  emscripten
Imguizmo.quat
ImGui GIZMO widget - 3D object manipulator / orientator
Stars: ✭ 187 (-13.82%)
Mutual labels:  emscripten
Symphonia
Pure Rust multimedia format demuxing, tag reading, and audio decoding library
Stars: ✭ 191 (-11.98%)
Mutual labels:  media
Shaden
🎧 A modular audio synthesizer.
Stars: ✭ 175 (-19.35%)
Mutual labels:  media
Yt Dlc
media downloader and library for various sites.
Stars: ✭ 2,590 (+1093.55%)
Mutual labels:  media
Jq Web
jq in the browser with emscripten.
Stars: ✭ 188 (-13.36%)
Mutual labels:  emscripten
Supermariowar
A fan-made multiplayer Super Mario Bros. style deathmatch game
Stars: ✭ 200 (-7.83%)
Mutual labels:  emscripten
Filepicker
FilePicker library for Android
Stars: ✭ 181 (-16.59%)
Mutual labels:  media
Atgmediabrowser
Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.
Stars: ✭ 186 (-14.29%)
Mutual labels:  media
Wiv
Window image viewer [DEPRECATED]
Stars: ✭ 196 (-9.68%)
Mutual labels:  media
Ffmpeg.js
Port of FFmpeg with Emscripten
Stars: ✭ 2,447 (+1027.65%)
Mutual labels:  emscripten
Engine
A basic cross-platform 3D game engine
Stars: ✭ 208 (-4.15%)
Mutual labels:  emscripten
Webassembly Examples
From Simple To Complex. A complete collection of webassembly examples.
Stars: ✭ 177 (-18.43%)
Mutual labels:  emscripten
Libvlc Go
Go bindings for libVLC and high-level media player interface
Stars: ✭ 188 (-13.36%)
Mutual labels:  media
Artipub
Article publishing platform that automatically distributes your articles to various media channels
Stars: ✭ 2,685 (+1137.33%)
Mutual labels:  media
Backend
Media Cloud is an open source, open data platform that allows researchers to answer quantitative questions about the content of online media.
Stars: ✭ 211 (-2.76%)
Mutual labels:  media
Unsilence
Console Interface and Library to remove silent parts of a media file 🔈
Stars: ✭ 197 (-9.22%)
Mutual labels:  media

mediainfo.js

This is a JavaScript port of the excellent MediaInfoLib and can run directly in a browser or in Node.js. It is transpiled from C++ source code using Emscripten.

Demo

Try mediainfo.js in your browser: https://mediainfo.js.org

Usage

Browser

You can either use a CDN to include the script file directly in your page or use a JavaScript bundler like webpack.

  • CDN:
    <script type="text/javascript" src="https://unpkg.com/mediainfo.js/dist/mediainfo.min.js"></script>
  • Bundler: npm install mediainfo.js

Be aware that mediainfo.js is a WebAssembly port of MediaInfoLib. Thus it depends on MediaInfoModule.wasm which weighs around 2.4 MiB. The WASM module is loaded automatically and needs to be made available from the same location mediainfo.js is served from. This is the case for the CDN version. If you're using a bundler, you need to take care of this yourself. There are examples for React/webpack and Angular on how to achieve this.

Node.js

Install mediainfo.js from NPM.

$ npm install -g mediainfo.js

You can use it directly from the shell.

$ mediainfo.js /path/to/media.avi

Or use it as a library.

require('mediainfo.js')().then((mediainfo) => {
  // mediainfo ready…
})

Examples

API

MediaInfo(opts, successCallback, errorCallback)

Create an instance of mediainfo.

Defaults: opts = { chunkSize: 256*1024, coverData: false, format: 'object' }

  • chunkSize: Chunk size used by analyzeData (in bytes)
  • coverData: Whether to extract binary cover data (Base64-encoded)
  • format: Format of result value (choices: object, JSON, XML, HTML or text)
  • locateFile: Optional callback function to override MediaInfo.wasm location. Must return URL/path to file. Helpful if you want to serve MediaInfoModule.wasm from a custom location.
    (url, scriptDirectory) => pathToFile
  • Returns a Promise if no callback is given.
const MediaInfo = require('mediainfo.js')
MediaInfo(opts, callback, errorCallback)

Media files can be several gigabytes in size. The preferred way is to load data in chunks to prevent memory exhaustion. analyzeData is a helper method that facilitates this somewhat cumbersome process.

mediainfo.analyzeData(getSize, readChunk, cb)

Convenient method for analyzing a buffer chunk by chunk.

  • You need to provide two callback functions. They can either return a Promise or directly the value.
    • getSize() - Return total buffer size.
    • readChunk(size, offset) - Read data chunk of size with offset and return an Uint8Array.
  • Returns a Promise if no callback is given.

Low-level methods

The mediainfo object also exposes a number of low-level methods analogous to the MediaInfoLib buffer methods.

close(), inform(), openBufferContinue(data, size), openBufferContinueGotoGet(), openBufferFinalize(), openBufferInit(size, offset)

Build

Install Emscripten preferably using Emscripten SDK.

$ git clone https://github.com/emscripten-core/emsdk.git
$ cd emsdk
$ ./emsdk install 1.39.15
$ ./emsdk activate 1.39.15
$ source ./emsdk_env.sh
$ export PATH=$PATH:$(pwd)/upstream/bin # for wasm-opt

Note: Versions 1.39.16 and later of Emscripten give compile errors.

In the project root of mediainfo.js run the following to build.

$ npm install
$ npm run build

Find the resulting files mediainfo.js, mediainfo.min.js and mediainfo.wasm in the dist directory.

Tests

You can run a test suite against the dist build.

$ npm run test

License

This program is freeware under BSD-2-Clause license conditions: MediaInfo(Lib) License

This product uses MediaInfo library, Copyright (c) 2002-2020 MediaArea.net SARL.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].