This article outlines:
Nginx is a very good open source server, use it to do HLS or rtmp streaming media server is a very good choice. This paper introduces a simple method to quickly set up rtmp streaming media server, also known as RTSP retransmission, the data source is not read files, but use to obtain rtspnal stream after using FFmpeg retransmission. CSDN: [Email protected]
Development environment: centos6.4 (the main choice of Linux servers, more than 30% of the market share)
These bags are required.
Version number: Nginx 1.7.3 OpenSSL 1.0.2 rtmp-module (version unknown)
Resources: These are public network download resources, have the need for friends, you can send me email or comment messages. Email:[email protected]
Note: First compile OpenSSL and then compile Nginx
Compile options:
./configure--add-module=. /nginx-rtmp-module-master--without-http_rewrite_module--with-openssl=. /openssl-1.0.2-beta2
All the way through
Errors may occur at startup:
Starting Nginx:nginx: [Emerg] unknown directive "rtmp" In/etc/nginx/nginx.conf:9
The RTMP module is not recognized.
Another possibility, the original CentOS from the source installed Nginx, it does not have the RTMP module, need to uninstall.
After installing the compiled Nginx:
Enter:
/usr/local/nginx/sbin
./nginx-c/usr/local/nginx/conf/nginx.conf
(Note: The following need is the absolute address)
FFmpeg Push Stream (if there is no FLV file, you can use 264,ts these files to convert, ffmpeg common commands this blog another article also has a brief introduction)
Ffmpeg-re-i ipcam.flv-f flv Rtmp://localhost/myapp/test1
Ffmpeg-re-i ipcam.flv-f flv-b 20000000 rtmp://localhost/myapp/test1
Real-time RTSP to rtmp live stream (actually turn rtmp after a few seconds of delay, different clients are not necessarily consistent, we are testing here is jwplayer 3 seconds or so (behind the use of a flex scheme, time delay to 2s), stable can be in about 1 seconds, VLC player for 10 seconds longer ~_~! , the client will still use RTSP, so quickly, the general delay can be ignored, rtmp is originally designed for the web side)
The method of obtaining the RTSP stream can be referenced in another article: http://blog.csdn.net/gubenpeiyuan/article/details/19072223
Ffmpeg-re-i realstream.fifo-f flv-b 20000000 rtmp://localhost/myapp/test1
Realstream.fifo is the FIFO that is created. Command: Mkfifo Realstream.fifo
Start RTSP get nal add SPS and PPS bits, then turn on FIFO real-time write.
Use VLC test as follows:
The live stream can then be pushed to the RMP.
My solution is to live555 receive stream, stream the way to the FIFO, to do rtmp forwarding. There may be some delay, which friend has a better plan, welcome to exchange comments.
The framework is as follows: very simple and easy to integrate into the large streaming media framework.
Flex Scenario:
Appendix:
The rtmp configuration is as follows:
[Plain]View PlainCopy
- #user nobody;
- Worker_processes 1;
- #error_log Logs/error.log;
- #error_log Logs/error.log Notice;
- #error_log Logs/error.log Info;
- #pid Logs/nginx.pid;
- 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;
- }
- Application HLS {
- Live on;
- HLS on;
- Hls_path/tmp/app;
- Hls_fragment 5s;
- }
- }
- }
- HTTP {
- Include Mime.types;
- Default_type Application/octet-stream;
- #log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
- # ' $status $body _bytes_sent ' $http _referer '
- # ' "$http _user_agent" "$http _x_forwarded_for" ';
- #access_log Logs/access.log Main;
- Sendfile on;
- #tcp_nopush on;
- #keepalive_timeout 0;
- Keepalive_timeout 65;
- #gzip on;
- server {
- Listen 80;
- server_name localhost;
- #charset Koi8-r;
- #access_log Logs/host.access.log Main;
- Location/{
- root HTML;
- Index index.html index.htm;
- }
- #error_page 404/404.html;
- # REDIRECT Server error pages to the static page/50x.html
- #
- Error_page 502 503 504/50x.html;
- Location =/50x.html {
- root HTML;
- }
- # Proxy The PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # Proxy_pass http://127.0.0.1;
- #}
- # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.php$ {
- # root HTML;
- # Fastcgi_pass 127.0.0.1:9000;
- # Fastcgi_index index.php;
- # Fastcgi_param Script_filename/scripts$fastcgi_script_name;
- # include Fastcgi_params;
- #}
- # Deny access to. htaccess files, if Apache ' s document Root
- # concurs with Nginx ' s one
- #
- #location ~/\.ht {
- # Deny All;
- #}
- }
- # Another virtual host using mix of ip-, name-, and port-based configuration
- #
- #server {
- # Listen 8000;
- # Listen somename:8080;
- # server_name somename alias Another.alias;
- # location/{
- # root HTML;
- # index index.html index.htm;
- # }
- #}
- # HTTPS Server
- #
- #server {
- # Listen 443 SSL;
- # server_name localhost;
- # ssl_certificate Cert.pem;
- # Ssl_certificate_key Cert.key;
- # Ssl_session_cache shared:ssl:1m;
- # ssl_session_timeout 5m;
- # ssl_ciphers high:!anull:! MD5;
- # ssl_prefer_server_ciphers on;
- # location/{
- # root HTML;
- # index index.html index.htm;
- # }
- #}
- }
Reference article:
Nginx RTMP Protocol Server
Http://www.cnblogs.com/aHuner/p/3247068.html
Build a flash live environment with open source Nginx-rtmp-module
Http://www.rosoo.net/a/201307/16696.html
Nginx to build HLS streaming media server
http://blog.csdn.net/cjsafty/article/details/7922849
The HLS live system based on nginx (recording the problem and solution of rtmp)
http://blog.csdn.net/cjsafty/article/details/9108587
C + + implements RTMP protocol to send H. Encode and AAC encoded audio and video
Http://www.cnblogs.com/haibindev/archive/2011/12/29/2305712.html
CentOS Install Flashplayer Plugin
Http://www.linuxidc.com/Linux/2013-03/81073.htm
FFmpeg Push Stream
Ffmpeg-re-i ~/2012.flv-f flv Rtmp://192.168.1.102/myapp/test1
Ffmpeg-re-i ipcam.h264-vcodec copy-f flv-b 20000000 rtmp://localhost/myapp/test1
from:http://blog.csdn.net/gubenpeiyuan/article/details/38089013
Nginx+ffmpeg set up rtmp to broadcast RTSP streaming flash server