GithubHelp home page GithubHelp logo

stremio / mediainfo.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from buzz/mediainfo.js

0.0 0.0 0.0 8.9 MB

MediaInfo ported to the web using emscripten

Home Page: https://mediainfo.js.org

License: BSD 2-Clause "Simplified" License

Shell 0.08% JavaScript 5.28% C++ 2.39% TypeScript 92.25%

mediainfo.js's Introduction

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

import MediaInfoFactory from 'mediainfo.js'

MediaInfoFactory().then((mediainfo) => {
  mediainfo.analyzeFile(...)
})

See the API docs for detailed instructions.

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"></script>
  • Bundler: npm install mediainfo.js

WASM file loading

Be aware that mediainfo.js needs to load the MediaInfoModule.wasm file (around 3.5 MiB). The WASM module is loaded and instantiated automatically. By default its load path is determined from the script location. This works out-of-the-box for the UMD and Node.js version.

โ—๏ธ If using a bundler, you need to ensure the module loader can fetch the WASM file by configuring your bundler/web server accordingly (examples).

Note that you can override the WASM file location by specifying a custom locateFile function to MediaInfoFactory.

Node.js

Install mediainfo.js from NPM.

$ npm install -g mediainfo.js

It can be used as a CLI from the shell.

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

Or use it as a library.

Examples

Build

Install Emscripten preferably using Emscripten SDK.

$ git clone https://github.com/emscripten-core/emsdk.git
$ cd emsdk
$ ./emsdk install latest
$ ./emsdk activate latest
$ source ./emsdk_env.sh

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

$ pnpm install
$ pnpm build

Find the resulting files in the dist directory.

Tests

You can run a test suite against the dist build.

$ pnpm test

License

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

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

mediainfo.js's People

Contributors

buzz avatar tannerrogalsky avatar corbenf-shuttlerock avatar craftycodie avatar davidlyons avatar tayles avatar elkindev avatar iwestlin avatar trendy avatar matthewleon avatar tymmesyde avatar tomwilsonmerkle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.