MP4 Stream Player - Megh Computing

Plays a (live) fragmented MP4 stream in an HTML video element using the Media Source Extensions (MSE) API.
This package cannot be used to play pre-recorded video unless the video data is appended to the player at the playback rate (real-time),
which is not typically feasible without decoding/parsing the MP4 file and inspecting the sample timings.
Features
- Hybrid package: CommonJS and ESM supported
- Modern (ES2020+) browsers supported: Chrome, Edge, and Firefox all work with acceptable performance
- First-class TypeScript support
Environment
This package only works in the browser.
Firefox seems to have performance issues decoding live video using MSE.
Installation
Install the package as a dependency using npm:
$ npm install @megh-computing/mp4-stream-player
or, install using yarn:
$ yarn add @megh-computing/mp4-stream-player
Example Usage
import {MP4StreamPlayer} from "@megh-computing/mp4-stream-player";
...
const player: MP4StreamPlayer = new MP4StreamPlayer();
player.on("error", (type, message) => {
console.error("Decode error:", type, message);
player.dispose("decode");
socket.close(4000, "decode error");
});
player.setFastForwardThreshold(0.25);
player.setSeekThreshold(1.0);
player.setPruneThreshold(120.0);
player.setPruneTimeSpan(30.0);
...
player.play();
...
player.append(data);
...
player.dispose();
License
Copyright (c) 2023 Megh Computing, Inc.
All rights reserved. No warranty, explicit or implied, provided.
Unauthorized use, modification, or distribution is strictly prohibited.
Homepage: https://megh.com/
Please contact us if you use Megh VAS and would like to be issued a license to use this package.