Git Product home page Git Product logo

jsmpeg-player's Introduction

JSMpeg Player(TS Player)

NPM version build status David deps devDependencies Status node version npm download npm license

  • JSMpeg player is based on jsmpeg.
  • The video must be compressed into the TS format of MPEG1 / MP2.
  • Apple device automatically plays without sound, you need to guide the user to click on the video in the lower right corner of the video icon to unlock the sound.(no similar problem in non-autoplay mode)

Releases | Demo

How to use

Install

$ npm install jsmpeg-player --save
# or
$ yarn add jsmpeg-player

Usage

import JSMpeg from 'jsmpeg-player';
# OR
let JSMpeg = require('jsmpeg-player');
new JSMpeg.VideoElement(videoWrapper, videoUrl, [, options])
  • videoWrapper: [string|element] the wrapper of video. Height and width of wrapper must be initialized

  • videoUrl: [string] a url to an MPEG .ts file

  • The options supports:

    • poster: [string] URL to an image to use as the poster to show before the video plays.(Recommended to set it manually)
    • autoplay: [boolean] whether to start playing immediately. Default false.
    • loop: [boolean] whether to loop the video (static files only). Default false.[overwrite]
    • aspectPercent: [string] Aspect ratio converted to percentage. E.g: '16:9' => '56.25%'. Default '56.25%'.
    • picMode: [boolean] picture node (no playButton). Default false.
    • chunkSize the chunk size in bytes to load at a time. Default 1024*1024 (1mb).
    • hookInPlay: [function] The hook function when the video play.
    • hookInPause: [function] The hook function when the video pause.
    • hookInStop: [function] The hook function when the video stop.
    • More options can view the jsmpeg options
  • JSMpeg.VideoElement instance supports the following methods:

    • destroy(): Empty videoWrapper.
  • JSMpeg.VideoElement.player instance API can view the JSMpeg.Player API

Use in browser

<div id="videoWrapper"></div>
<script src="JSMpeg.min.js"></script>
<script>
  var videoUrl = '../static/media/test_video.ts';
  new JSMpeg.VideoElement('#videoWrapper', videoUrl);
</script>

Encoding Video/Audio for jsmpeg by ffmpeg. E.g:

$ ffmpeg -i input.mp4 -f mpegts
         -codec:v mpeg1video -s 640x360 -b:v 700k -r 25 -bf 0
         -codec:a mp2 -ar 44100 -ac 1 -b:a 64k
         output.ts
  • options
    • -s: video size
    • -b:v: video bit rate
    • -r: frame rate
    • -ar: sampling rate
    • -ac: number of audio channels
    • -b:a: audio bit rate

jsmpeg-player's People

Contributors

cycjimmy avatar

Watchers

James Cloos avatar Radu Rizea 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.