New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@megh-computing/mp4-stream-player

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@megh-computing/mp4-stream-player

Plays a fragmented MP4 stream in a video element

latest
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

MP4 Stream Player - Megh Computing

npm npm dependencies node npm type definitions

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";

...

// Create player and configure events
const player: MP4StreamPlayer = new MP4StreamPlayer();
player.on("error", (type, message) => {
    console.error("Decode error:", type, message);
    // Dispose player with reason
    player.dispose("decode");
    // Close MP4 socket
    socket.close(4000, "decode error");
    // Re-connect to MP4 socket?
});

// Optional configuration (defaults provided)
player.setFastForwardThreshold(0.25); // How far behind live can the player get before playback is set to 2x
player.setSeekThreshold(1.0); // How far behind live can the player get before seeking to live
player.setPruneThreshold(120.0); // How old media data is before it's pruned
player.setPruneTimeSpan(30.0); // How much media data is pruned at a time

...

// Start the player
player.play();

...

// Append MP4 data to the player
player.append(data);

...

// If the stream restarts (indicated by the socket closing),
// then dispose the player and create a new one when the socket reconnects
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.

FAQs

Package last updated on 10 Jan 2023

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