赞
踩
var WebApp = require('webapp');
var MediaDecoder = require('mediadecoder');
var WebMedia = require('webmedia');
var opts = {
mode: 1,
path: '/live.flv',
mediaSource: {
source: 'flv',
},
streamChannel: {
protocol: 'xhr',
},
}
var server = WebMedia.createServer(opts, app);
var opts = {
mode: 1,
path: '/live.flv',
mediaSource: {
source: 'flv',},
streamChannel: {
protocol: 'ws',
server: wsSer
},
}
var server = WebMedia.createServer(opts, app);
server.on('start', () => { var netcam = new MediaDecoder().open('rtsp://192.168.128.102:8554/live.sdp', {proto: 'tcp'}, 5000); netcam.destVideoFormat({width: 640, height: 360, fps: 1, pixelFormat: MediaDecoder.PIX_FMT_RGB24, noDrop: false, disable: false}); netcam.destAudioFormat({disable: false}); netcam.remuxFormat({enable: true, enableAudio: true, audioFormat:'aac', format: 'flv'}); netcam.on('remux', (frame) => { var buf = Buffer.from(frame.arrayBuffer); server.pushStream(buf); }); netcam.on('header', (frame) => { var buf = Buffer.from(frame.arrayBuffer); server.pushStream(buf); }); netcam.start(); });
<html> <div> <canvas id="video1" style="width:640px;height:480px;background-color: black;"></canvas> </div> <body> <script type="text/javascript" src="./NodePlayer.min.js"></script> <script> var player; NodePlayer.load(()=>{ player = new NodePlayer(); }); player.setView("video1"); player.on("start", () => { // 当连接成功并收到数据 }); player.on("stop", () => { // 当本地stop或远端断开连接 }); player.on("error", (e) => { // 当连接错误或播放中发生错误 }); player.on("videoInfo", (w, h) => { //当解析出视频信息时回调 console.log("player on video info width=" + w + " height=" + h); }) player.on("audioInfo", (r, c) => { //当解析出音频信息时回调 console.log("player on audio info samplerate=" + r + " channels=" + c); }) player.on("stats", (stats) => { // 每秒回调一次流统计信息 console.log("player on stats=", stats); }) player.setVolume(1000) player.start("http://192.168.128.1:10002/live.flv"); </script> </body> </html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。