MPEG2-TS ストリームを HTML5 上で再生するビデオプレーヤーです。
mpegts.js はライブ配信に対し、低遅延再生のために最適化しています。DVB/ISDB のテレビチャンネルや監視カメラの映像等を低遅延で再生可能になります。
mpegts.js は flv.js を基づいて作ってきたものです。
mpegts.js は、JavaScript で MPEG2-TS ストリームを解析しながら、映像と音声のデータを ISO BMFF (fmp4) フォーマットのフラグメントにリマックスして、Media Source Extensions を通じて <video>
要素に提供することで再生することにしています。
http://xqq.github.io/mpegts.js/demo/
.m2ts
ファイル(BDAV/BDMV)、または 204 bytes も再生可能MPEG2-TS ストリームが別のサーバー上にある場合、Access-Control-Allow-Origin
は必須です。
cors.md を参照してください。
npm install --save mpegts.js
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
<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 をテストすることができます。
multipart.md を参照
livestream.md を参照
api.md を参照
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.md を参照
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.