1、申请ID:dongwn
2、个人邮箱:dongwnletter@126.com
3、原创技术文章:写了多年javaweb端,老弟我热爱编程,在csdn上写了点小记录(三人行必有我师)
截图
!([img]https://img-blog.csdnimg.cn/20201208163509110.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzM3NjE1NDU4,size_16,color_FFFFFF,t_70)
!([img]https://img-blog.csdnimg.cn/20201208163641177.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzM3NjE1NDU4,size_16,color_FFFFFF,t_70)
申请举例-------实现直播功能
csdn博客地址 https://blog.csdn.net/m0_37615458/article/details/102811550
个人博客地址 https://www.dongwn.icu //已经安装SSL证书,服务器为阿里云,基于github开源项目halo搭建。
- 使用obs推流 (自行下载),srs(自行搭建)作为直播服务器 video.js拉取rtmp媒体流。
- srs配置,开始服务器录制直播视频、自定义录制视频存放地址,开启http回调,详看下方配置
- obs配置看图,推流地址 rtmp://192.168.x.x/str str自定义 串流秘钥key自定义
- video.js(自行下载)配置 注意拉流地址例 rtmp://192.168.x.x/str/key 既与推流地址一致
srs服务器配置
listen 1935;
max_connections 1000;
srs_log_tank file;
srs_log_file ./objs/srs.log;
http_api {
enabled on;
listen 1985;
}
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
stats {
network 0;
disk sda sdb xvda xvdb;
}
vhost __defaultVhost__ {
gop_cache off;
queue_length 10;
min_latency on;
mr {
enabled off;
}
mw_latency 100;
tcp_nodelay on;
dvr {
enabled on;
dvr_path /mnt/data/ean-upload/flv/[15].[04].[05].[999].flv;#自定义的文件存放地址,命名生成规则自行看文档
dvr_plan session;
dvr_duration 30;
dvr_wait_keyframe on;
time_jitter full;
}
http_hooks {
enabled on;
on_dvr [http://ip:8061/open/api/public/course/flvCallBack;](http://192.168.2.101:8061/open/api/public/course/flvCallBack;) #配置的dvr录制完视频后http回调地址
}
}
video.js配置如下
-------------
以上为申请内容,祝工作顺利,身体健康。
var player = videojs('example_video_1', {
preload: 'auto',
//poster: '/statics/images/ean.png',//封面
title: 'ean',
author: 'dongwn',
width: '1px',
height: '439px',
controls: true,
'autoplay': true,
sources: [{
src: Page.RtmpUrl + Page.roomId + '/' + Page.secretKey,//srs地址与推流地址一致,url/str/key
type: 'rtmp/flv'
}]
}, function () {
player.on('ended', function (e) {
window.console.log('videoJS: ended');
});
player.on('error', function (e) {
window.console.log('videoJS: error');
});
player.on('pause', function (e) {
window.console.log('videoJS: pause');
});
player.on('waiting', function (e) {
window.console.log('videoJS: waiting');
});
player.on('play', function (e) {
window.console.log('videoJS: play (adState: ' + player.ads.state + ')');
});
player.on('ads-ad-started', function (e) {
window.console.log('videoJS/Ads: ads-ad-started');
});
});
以上为申请内容,祝工作顺利,身体健康。