mpegts.js npm

MPEG2-TS ストリームを HTML5 上で再生するビデオプレーヤーです。

mpegts.js はライブ配信に対し、低遅延再生のために最適化しています。DVB/ISDB のテレビチャンネルや監視カメラの映像等を低遅延で再生可能になります。

mpegts.js は flv.js を基づいて作ってきたものです。

Overview

mpegts.js は、JavaScript で MPEG2-TS ストリームを解析しながら、映像と音声のデータを ISO BMFF (fmp4) フォーマットのフラグメントにリマックスして、Media Source Extensions を通じて <video> 要素に提供することで再生することにしています。

Demo

http://xqq.github.io/mpegts.js/demo/

demo with aribb24.js

Features

CORS

MPEG2-TS ストリームが別のサーバー上にある場合、Access-Control-Allow-Origin は必須です。

cors.md を参照してください。

Installation

npm install --save mpegts.js

Build

npm install                 # install dev-dependences
npm install -g webpack-cli  # install build tool
npm run build               # packaged & minimized js will be emitted in dist folder

Getting Started

<script src="mpegts.js"></script>
<video id="videoElement"></video>
<script>
    if (mpegts.getFeatureList().mseLivePlayback) {
        var videoElement = document.getElementById('videoElement');
        var player = mpegts.createPlayer({
            type: 'mse',  // could also be mpegts, m2ts, flv
            isLive: true,
            url: 'http://example.com/live/livestream.ts'
        });
        player.attachMediaElement(videoElement);
        player.load();
        player.play();
    }
</script>

Simple Realtime Server を用いて mpegts.js をテストすることができます。

TODO

Limitations

Features inherited from flv.js

FLV playback limitations

FLV Multipart playback

multipart.md を参照

Livestream playback

livestream.md を参照

API and Configuration

api.md を参照

Debug

npm install                 # install dev-dependences
npm install -g webpack-cli  # install build tool
npm run build:debug         # packaged & minimized js will be emitted in dist folder

Design

design.md を参照

License

Copyright (C) 2021 magicxqq. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.