RTMP & RTSP
RTSP+RTP主要用于IPTV,原因是传输数据使用的是UDP,在网络环境比较稳定的情况下,传输效率是比较高的;
RTMP主要用于互联网音视频传输,它使用的是TCP传输,因为互联网环境相对较差,采用RTMP保证了视频的传输质量,但是其传输延迟相对较高,传输效率相对较低。
https://zhuanlan.zhihu.com/p/382713315
RTSP、RTMP区别
- RTSP实时流协议
RTSP可以对流媒体提供诸如播放、暂 停、快进等操作,它负责定义具体的控制消息、操作方法、状态码等,此外还描述了与RTP间的交互操作(RFC2326)。
- RTMP和延时
一般的直播应用,只要不是电话类对话的那种要求,RTMP延迟是可以接受的。在一般的视频会议应用中,RTMP延时也能接受,原因是别人在说话的时候我们一般在听.
安装教程
https://www.likecs.com/show-61334.html
https://blog.youkuaiyun.com/weixin_40359716/article/details/104645108
https://blog.youkuaiyun.com/lingdu_789/article/details/124297354
安装yasmhttps://blog.youkuaiyun.com/qq_16504067/article/details/114524541
安装ffmpeghttps://cloud.tencent.com/developer/article/1408113
部分介绍https://github.com/winlinvip/srs/tags
SRS下载地址 4.0版本以上https://blog.youkuaiyun.com/weixin_41910694/article/details/122704791
edgehttps://blog.youkuaiyun.com/mangobot/article/details/121426189
疑似暂停
基于宝塔服务安装部分功能,包括nginx,ssh连接配置,文件上传下载服务.直接在宝塔服务面板进行操作即可.
方便文件上传下载,部分nginx和srs的配合,ssh终端自动连接的功能
1.0 虚拟机网络设置为NAT
nano /etc/sysconfig/network-scripts/ifcfg-ens33
parse : ONBOOT=yes
在虚拟机的环境中,重启网络即可,命令为
service NetworkManager stop
service network restart
service NetworkManager start
2.0 修改镜像源
-
备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
-
下载新的CentOS-Base.repo 到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
-
生成缓存
yum makecache
3.0 开启端口
firewall-cmd --zone=public --add-port=8000/tcp --permanent && firewall-cmd --reload
4.0 防火墙
启动:systemctl start firewalld
停止:systemctl disable firewalld
禁用:systemctl stop firewalld
5.0 开关SRS
-
编译:
./configure && make
-
开启服务:
./objs/srs -c conf/srs.conf
-
停止服务:
./scripts/stop.sh
./etc/init.d/srs stop
-
热重启
killall -1 srs
-
编译时安装FFmpeg:
./configure --with-ffmpeg
6.0 安装 yasm
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar zxvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make && make install
7.0 解压 tar.xz 文件
tar -xf archive.tar.xz
8.0 rtmp 文件推拉流
ffmpeg -re -i filePath_video_file -c copy -f flv -y rtmp://ipAddres/live/livestream
- VLC观看
- cmd终端
ffpaly rtmp://ipAddres/live/livestream
9.0 obs推流
- 推流设置
- 拉流
10.0 webRTC推流
- 推流
这里需要注意,仅支持https. 推流的是摄像头实时视频。
- 拉流
11.0 webRTC推流
- 视频推流
ffmpeg -i 0512_1.mp4 -vcodec copy -acodec copy -y -f flv rtmp:82.156.3.9:1935/live/test_1
12.0 HLS协议文件
hls {
# enabled on;
# hls_fragment 10;
# hls_window 60;
# hls_ts_file [app]/[stream]/[2006][01][02]-[15][04][05]-[seq].ts; # ts文件在/objs/nginx/html下的路径
# hls_path ./objs/nginx/html;
# hls_m3u8_file [app]/[stream].m3u8;
# hls_cleanup off;
# hls_dispose 86400;
# hls_on_error continue;
# hls_storage disk;
# hls_wait_keyframe on;
# hls_acodec aac;
# hls_vcodec h264;
enabled on;
hls_fragment 5;
hls_window 86400; #ts总时长1天
hls_path ./objs/nginx/html; #m3u8和ts文件的相对路径
hls_m3u8_file [app]/[stream].m3u8; # m3u8文件在/objs/nginx/html下的路径
hls_ts_file [app]/[stream]/[2006][01][02]-[15][04][05]-[seq].ts; # ts文件在/objs/nginx/html下的路径
hls_cleanup off; #不清除过期的ts文件
hls_dispose 86400; # 在没有流时,HLS清理的过期时间为1天
}