-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrtmp.html
78 lines (78 loc) · 3.4 KB
/
rtmp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta http-equiv=pragma content=no-cache>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.ico">
<link rel="bookmark" href="favicon.ico">
<title>rtmp安装配置笔记</title>
<style>pre {white-space: pre-wrap;white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap;word-wrap: break-word;}</style>
</head>
<body style="margin:20px">
<p><a href="index.html">返回首页</a></p>
<h2 align=center>rtmp安装配置笔记</h2>
<h3>注:网站系统为CentOS 7,使用systemd。</h3>
<p><b>一、编译安装NGINX</b></p>
<p>安装依赖</p>
<pre>yum install pcre-devel zlib-devel -y</pre>
<p>建立组和用户并设置不能ssh登录</p>
<pre>useradd -U -r -M -s /bin/false www</pre>
<p>下载</p>
<pre>cd /data/source
wget http://nginx.org/download/nginx-1.21.5.tar.gz</pre>
<p>解压</p>
<pre>tar xvf nginx-1.21.5.tar.gz
cd nginx-1.21.5
git clone https://github.com/arut/nginx-rtmp-module.git
./configure --prefix=/usr/local/nginx --user=www --group=www --pid-path=/run/nginx.pid --lock-path=/run/nginx.lock --http-client-body-temp-path=/tmp/client --http-proxy-temp-path=/tmp/proxy --http-fastcgi-temp-path=/tmp/fastcgi --http-uwsgi-temp-path=/tmp/uwsgi --http-scgi-temp-path=/tmp/scgi --http-log-path=/usr/local/nginx/log/access.log --error-log-path=/usr/local/nginx/log/error.log --with-http_ssl_module --with-http_v2_module --with-stream_realip_module --with-http_stub_status_module --add-module=nginx-rtmp-module
make -j8
</pre>
<p>出现this statement may fall through [-Werror=implicit-fallthrough=]错误,解决办法:</p>
<pre>#sed -i "s/-Werrori //g" objs/Makefile</pre>
<p>重新make即可</p>
<p><b>二、rtmp配置(添加hls支持)</b></p>
<p>在nginx.conf中的http后面添加(与http协议并列)</p>
<pre>rtmp {
server {
listen 1935;
application live {
live on;
hls on;
hls_path /data/www/live;
hls_fragment 5s;
}
}
}
</pre>
<p>说明:</p>
<ul>
<li>rtmp是协议名称</li>
<li>server 说明内部中是服务器相关配置</li>
<li>listen 监听的端口号, rtmp协议的默认端口号是1935</li>
<li>application 访问的应用路径是 zbcs</li>
<li>live on; 开启实时</li>
<li>hls on; 开启hls</li>
<li>hls_path /data/www/live; hls推流请求路径</li>
<li>hls_fragment 5s; 每个ts文件包含5秒的视频内容</li>
</ul>
<p><b>三、工具推流</b></p>
<p>1、用ffmpeg推流</p>
<pre>ffmpeg -re -i /data/v.mp4 -vcodec copy -f flv rtmp://127.0.0.1/live/test</pre>
<p>2、用OBS Studio推流(开源、跨平台软件,强烈推荐)</p>
<p>下载地址:<a href="https://obsproject.com/" target="_blank">OBS</a></p>
<p>3、手机端推流</p>
<p><a href="http://www.nodemedia.cn/products/QLive/" target="_blank">快直播</a></p>
<p><b>四、播放器播放</b></p>
<p>1、播放器:用支持rtmp或m3u8格式的播放器观看直播,如vlc或smplayer</p>
<p>2、播放地址:</p>
<pre>rtmp://127.0.0.1/live/test
http://127.0.0.1/live/test.m3u8</pre>
<p><b>*五、服务器端用网页推流和播放(H5或flash)</b></p>
<p>1、软件:videojs+videojs-flash</p>
<p>未完待续。。。</p>
<p><a href="index.html">返回首页</a></p>
<p align="center">© 2016-2025 清风的个人笔记</p>
</div>
</body>
</html>