Simple Live System Using Nginx
1. Install nginx
su
mkdir /usr/local/nginx
cd /usr/local/nginx
apt-get install libssl-dev
tar xvf nginx-http-flv-module-1.2.7.tar.gz
tar xvf nginx-1.17.5.tar.gz
cd nginx-1.17.5
./configure --with-http_ssl_module --add-module=../nginx-http-flv-module-1.2.7
make && make install
2. Edit nginx.conf
cp nginx-http-flv-module-1.2.7/test/nginx.conf /usr/local/nginx/conf/
worker_processes 1; error_log logs/error.log debug; events {
worker_connections 1024;
} rtmp {
server {
listen 1935; application myapp {
live on; #record keyframes;
#record_path /tmp;
#record_max_size 128K;
#record_interval 30s;
#record_suffix .this.is.flv; #on_publish http://localhost:8080/publish;
#on_play http://localhost:8080/play;
#on_record_done http://localhost:8080/record_done;
}
}
} http {
server {
listen 8002; location /live{
flv_live on;
} location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
} location /stat.xsl {
root /usr/local/nginx/nginx-http-flv-module-1.2.7/;
} location /control {
rtmp_control all;
} #location /publish {
# return 201;
#} #location /play {
# return 202;
#} #location /record_done {
# return 203;
#} location /rtmp-publisher {
root /usr/local/nginx/nginx-http-flv-module-1.2.7/test;
} location / {
root /usr/local/nginx/nginx-http-flv-module-1.2.7/test/www;
}
}
}
Reference example:
Example Assume that listen directive specified in http block is: http {
...
server {
listen 8080; #not default port 80
... location /live {
flv_live on;
}
}
} And listen directive specified in rtmp block is: rtmp {
...
server {
listen 1985; #not default port 1935
... application myapp {
live on;
}
}
}
3. Startup nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#ps -ef|grep nginx
#kill -TERM 2132 or kill -INT 2132
#pkill -9 nginx
#./nginx -t
#./nginx -s reload
4. push rtmp stream
ffmpeg -re -i source.200kbps.768x320.flv -c copy -f flv rtmp://127.0.0.1:1935/myapp/mystream
5. player
rtmp://localhost:1935/myapp/mystream
http://localhost:8002/live?port=1935&app=myapp&stream=mystream
6. Other optimized configuration
worker_processes 10;
events {
worker_connections 10240;
}
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;
rtmp{
out_queue 4096;
out_cork 8;
max_streams 128;
timeout 15s;
drop_idle_publisher 15s;
log_interval 5s;
log_size 1m;
server{
listen 9000;
server_name 127.0.0.1;
application myapp{
live on;
gop_cache on;
}
application hls{
live on;
hls on;
hls_path /usr/local/nginx/html/hls;
}
application dash{
live on;
dash on;
dash_path /usr/local/nginx/html/dash;
} }
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8002;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /live{
flv_live on;
chunked_transfer_encoding on;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
}
location /hls{
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /usr/local/nginx/html/hls;
add_header 'Cache-Control' 'no-cache';
}
location /dash {
root /usr/local/nginx/html/dash;
add_header 'Cache-Control' 'no-cache';
} location /stat {
#configuration of push & pull status
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/local/nginx/nginx-http-flv-module-1.2.7;
} location /control {
rtmp_control all; #configuration of control module of rtmp
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
} }
rtmp
rtmp://example.com[:port]/myapp/mystream
hls
http://example.com[:port]/dir/streamname.m3u8
dash
http://example.com[:port]/dir/streamname.mpd
7. Reference design:
https://github.com/winshining/nginx-http-flv-module
https://blog.csdn.net/caowenjing123/article/details/94623466
Simple Live System Using Nginx的更多相关文章
- Building simple plug-ins system for ASP.NET Core(转)
Recently I built plug-ins support to my TemperatureStation IoT solution web site. The code for .NET ...
- Simple GB28181 System
I. Deployment / Architecture Block Diagram II. Resources Used 1. freeswitch —— sip server and media ...
- 使用metricbeat监控system和nginx
下载并解压缩metricbeat metricbeat.yml配置文件设置: setup.kibana: host: "192.168.75.21:5601" output.ela ...
- Simple File System
This is my operating system class design. scanner.h #include<string> using namespace std; #pra ...
- Artix-7 50T FPGA试用笔记之Create a simple MicroBlaze System
前言:之前笔者的试用博文提到安富利这块板子非常适合MicroBlaze开发,同时网上关于MicroBlaze的资料非常少(或含糊不清),没有一篇能完整介绍VIVADO SDK的设计流程,所以笔者带来这 ...
- GB28181 To RTMP/HLS/HTTP-FLV/DASH Gateway
I. Deployment / Architecture Block Diagram II. Resources Used 1. freeswitch —— sip server https://f ...
- Nginx - Additional Modules, Content and Encoding
The following set of modules provides functionalities having an effect on the contents served to the ...
- CentOS7安装和配置Nginx(https)
安装Nginx下载安装包# wget http://nginx.org/download/nginx-1.11.7.tar.gz# tar -zxvf nginx-1.11.7.tar.gz# cd ...
- centos7 设置nginx和php开机自启动
nginx开机自启动 首先我是源码安装的,需要手动建立nginx.service服务文件 cd /lib/systemd/system touch nginx.service nginx.servic ...
随机推荐
- Internet History, Technology, and Security(week5)——Technology: Internets and Packets
前言: 之前都在学习Internet的历史,从这周开始,进入到了Internet技术的学习. Layer1: Link Introduction / The Link Layer 80年代之前,主流网 ...
- android平台上AES,DES加解密及问题
在使用java进行AES加密的时候,会用到如下方法: SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); 但是在andr ...
- #1114-JSP指令
JSP 指令 JSP指令用来设置整个JSP页面相关的属性,如网页的编码方式和脚本语言. 语法格式如下: <%@ directive attribute = "value"%& ...
- 获取oracle数据库对象定义
在oracle中,使用DBMS_METADATA包中的GET_DDL函数来获得对应对象的定义语句.GET_DDL函数的定义如下: DBMS_METADATA.GET_DDL ( object_type ...
- qbzt day2 晚上(竟然还有晚上)
内容提要 搜索 拓展欧几里得 逆元 先是搜索 A* 有几个数组 g 当前点到根节点的深度 h 当前点到终点理想的最优情况需要走几步 f f=g+h A*就是把所有的f从小到大排序 启发式搜索相较于其 ...
- VMware 虚拟化编程(12) — VixDiskLib Sample 程序使用
目录 目录 前文列表 vixDiskLibSample 安装 Sample 程序 Sample 程序使用方法 前文列表 VMware 虚拟化编程(1) - VMDK/VDDK/VixDiskLib/V ...
- Linux_DHCP&DHCP Relay
目录 目录 DHCP DHCP Relay Setup DHCPServer Setup ClientPort DHCPDHCPRelay Setup DHCPRelay service DHCP D ...
- spring boot配置项profiles active
结论:通用项配置在applicaton.yml,区别环境配置在application-{profile}.yml中 一直不知道这个参数要不要配,配了有什么用,今天搭一个工程来检验 此项作用:用来区分不 ...
- #Week 11 - 343.Integer Break
Week 11 - 343.Integer Break Given a positive integer n, break it into the sum of at least two positi ...
- element-ui走马灯如何实现图片自适应 长度和高度 自适应屏幕大小
最近写用vue2.0写一个项目,用到了走马灯效果,由于项目赶时间,想偷下懒,第一次引用了element组件(纯JS也可以写的出来,赶时间嘛,懂得....),结果用了发现一个问题,element的组件( ...