Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsmpeglive

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsmpeglive

#### An MPEG1 Live Stream Video Decoder in JavaScript ####

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

jsmpeglive

An MPEG1 Video Decoder in JavaScript

jsmpeglive is a MPEG1 Live Video Decoder, written in JavaScript.

It receives a live stream, via WebSocket.

It is prepared to use any other Transport method available. It just needs to follow the same interface as the included built-in WebSocketClient.

This WebSocketClient has the logic to reconnect every 5 seconds

TODO: add some logarithmic/fibonacci/exponential back-off method

Setup

Run npm install and then npm start to start the HTTP and WebSockets server.

In an other terminal, Then, to start streaming, you can use a camera that provides a RTSP feed, or your own laptop

# Laptop Web cam feed
./start_ffmpeg_stream.sh /dev/video0

or

# Camera Feed
./start_ffmpeg_stream.sh "rtsp://192.168.1.54:554/axis-media/media.amp?videocodec=h264&resolution=640x480"

Building

To build, just run npm build

API

Constructor

var player = new jsmpeglive(uri[, options])

The uri argument accepts a WebSocket address for streaming playback.

The options argument to jsmpeglive() supports the following properties:

  • benchmark whether to log benchmark results to the browser's console
  • canvas the HTML Canvas element to use; jsmpeglive will create its own Canvas element if none is provided
  • ondecodeframe a function that's called after every frame that's decoded and rendered to the canvas

Examples

The best example is just checking the source code. Feel free to review stream-example.html.

Note that you have to include both WebSocketClient and jsmpeglive

var player = new jsmpeglive('ws://localhost:8084/', {canvas:canvas});

Diferences between jsmpeglive and jsmpeg

The Transport layer was removed from the main jsmpeg decoding object. Also, as I didn't need recording, it was removed, as well as all the functions for playing local video files.

Limitations

  • Only raw MPEG video streams are supported. The decoder hates Stream Packet Headers in between macroblocks.

You can use FFmpeg to encode videos in a suited format. Check start_ffmpeg_stream,sh, it has the parameters needed to crop the size to a multiple of 2, omit B-Frames and force a raw video stream.

Inspiration

It is based on the work of Dominic Szablewski's jsmpeg

jsmpeg is based on Java MPEG-1 Video Decoder and Player by Korandi Zoltan and inspired by MPEG Decoder in Java ME by Nokia.

FAQs

Package last updated on 22 Dec 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc