zhibo/live-streaming/server/utils/streamUrl.js

18 lines
529 B
JavaScript

// 生成流地址
const generateStreamUrls = (streamKey) => {
const host = process.env.SRS_HOST || 'localhost';
const rtmpPort = process.env.SRS_RTMP_PORT || 1935;
const httpPort = process.env.SRS_HTTP_PORT || 8080;
return {
// 推流地址 (给主播用)
rtmp: `rtmp://${host}:${rtmpPort}/live`,
// 播放地址 (给观众用)
flv: `http://${host}:${httpPort}/live/${streamKey}.flv`,
hls: `http://${host}:${httpPort}/live/${streamKey}.m3u8`
};
};
module.exports = { generateStreamUrls };