企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## **点播视频服务器的配置** 打开配置文件nginx.conf,添加RTMP的配置 ``` worker_processes 1; events { worker_connections 1024; } rtmp { #RTMP服务 server { listen 1935; #//服务端口 chunk_size 4096; #//数据传输块的大小 application vod { play /opt/video/vod; #//视频文件存放位置。 } } } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } ``` 配置目录/opt/video/vod为存放视频文件的位置了,那我们就往里面放一个文件吧。我放了一个**girl.mp4**文件。 文件放好之后,那就让我们重新启动一下nginx ``` sudo ./sbin/nginx -s reload ``` 拉流使用我们要点播的节目地址*rtmp://localhost/vod/girl.mp4* ## **直播视频服务器的配置** 接着我们就在点播服务器配置文件的基础之上添加直播服务器的配置。一共2个位置,第一处就是给RTMP服务添加一个application这个名字可以任意起,也可以起多个名字,由于是直播我就叫做它live吧,如果打算弄多个频道的直播就可以live\_cctv1、live\_cctv2名字任意。第二处就是添加两个location字段,字段的内容请直接看文件吧。 ``` worker_processes 1; events { worker_connections 1024; } rtmp { server { listen 1935; chunk_size 4096; application vod { play /opt/video/vod; } application live{ #第一处添加的直播字段 live on; } } } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location /stat { #第二处添加的location字段。 rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { #第二处添加的location字段。 root /etc/rtmpServer/nginx-rtmp-module/; } location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } ``` 添加完这两处之后,重新启动nginx打开浏览器看看,是否有如下图显示: ![](https://pic3.zhimg.com/80/v2-7bc470c3e555e61d22da7069f55587c0_720w.jpg) 推流的地址: rtmp://localhost:1935/live , 然后在串流密钥那写test,也可以随便写。使用vlc拉流的的地址就是 rtmp://localhost:1935/live/test ![](https://img.kancloud.cn/f4/b1/f4b18e4db8b3f109df7bab6cd99af8a2_844x471.png)