代码拉取完成,页面将自动刷新
//
// Created by Mingliang Chen on 18/3/16.
// illuspas[a]gmail.com
// Copyright (c) 2018 Nodemedia. All rights reserved.
//
const Logger = require('./node_core_logger');
const NodeCoreUtils = require("./node_core_utils");
const EventEmitter = require('events');
const { spawn } = require('child_process');
const RTSP_TRANSPORT = ['udp', 'tcp', 'udp_multicast', 'http'];
class NodeRelaySession extends EventEmitter {
constructor(conf) {
super();
this.conf = conf;
this.id = NodeCoreUtils.generateNewSessionID();
this.TAG = 'relay';
}
run() {
let format = this.conf.ouPath.startsWith('rtsp://') ? 'rtsp' : 'flv';
let argv = ['-i', this.conf.inPath, '-c', 'copy', '-f', format, this.conf.ouPath];
if (this.conf.inPath[0] === '/' || this.conf.inPath[1] === ':') {
argv.unshift('-1');
argv.unshift('-stream_loop');
argv.unshift('-re');
}
if (this.conf.inPath.startsWith('rtsp://') && this.conf.rtsp_transport) {
if (RTSP_TRANSPORT.indexOf(this.conf.rtsp_transport) > -1) {
argv.unshift(this.conf.rtsp_transport);
argv.unshift('-rtsp_transport');
}
}
Logger.ffdebug(argv.toString());
this.ffmpeg_exec = spawn(this.conf.ffmpeg, argv);
this.ffmpeg_exec.on('error', (e) => {
Logger.ffdebug(e);
});
this.ffmpeg_exec.stdout.on('data', (data) => {
Logger.ffdebug(`FF输出:${data}`);
});
this.ffmpeg_exec.stderr.on('data', (data) => {
Logger.ffdebug(`FF输出:${data}`);
});
this.ffmpeg_exec.on('close', (code) => {
Logger.log('[Relay end] id=', this.id);
this.emit('end', this.id);
});
}
end() {
this.ffmpeg_exec.kill();
}
}
module.exports = NodeRelaySession;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。