Nginx+ffmpeg set up rtmp to broadcast RTSP streaming flash server

Source: Internet
Author: User
Tags flv file

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
  1. #user nobody;
  2. Worker_processes 1;
  3. #error_log Logs/error.log;
  4. #error_log Logs/error.log Notice;
  5. #error_log Logs/error.log Info;
  6. #pid Logs/nginx.pid;
  7. Events {
  8. Worker_connections 1024;
  9. }
  10. rtmp {
  11. server {
  12. Listen 1935;
  13. Application MyApp {
  14. Live on;
  15. #record keyframes;
  16. #record_path/tmp;
  17. #record_max_size 128K;
  18. #record_interval 30s;
  19. #record_suffix. this.is.flv;
  20. #on_publish Http://localhost:8080/publish;
  21. #on_play Http://localhost:8080/play;
  22. #on_record_done Http://localhost:8080/record_done;
  23. }
  24. Application HLS {
  25. Live on;
  26. HLS on;
  27. Hls_path/tmp/app;
  28. Hls_fragment 5s;
  29. }
  30. }
  31. }
  32. HTTP {
  33. Include Mime.types;
  34. Default_type Application/octet-stream;
  35. #log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
  36. # ' $status $body _bytes_sent ' $http _referer '
  37. # ' "$http _user_agent" "$http _x_forwarded_for" ';
  38. #access_log Logs/access.log Main;
  39. Sendfile on;
  40. #tcp_nopush on;
  41. #keepalive_timeout 0;
  42. Keepalive_timeout 65;
  43. #gzip on;
  44. server {
  45. Listen 80;
  46. server_name localhost;
  47. #charset Koi8-r;
  48. #access_log Logs/host.access.log Main;
  49. Location/{
  50. root HTML;
  51. Index index.html index.htm;
  52. }
  53. #error_page 404/404.html;
  54. # REDIRECT Server error pages to the static page/50x.html
  55. #
  56. Error_page 502 503 504/50x.html;
  57. Location =/50x.html {
  58. root HTML;
  59. }
  60. # Proxy The PHP scripts to Apache listening on 127.0.0.1:80
  61. #
  62. #location ~ \.php$ {
  63. # Proxy_pass http://127.0.0.1;
  64. #}
  65. # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  66. #
  67. #location ~ \.php$ {
  68. # root HTML;
  69. # Fastcgi_pass 127.0.0.1:9000;
  70. # Fastcgi_index index.php;
  71. # Fastcgi_param Script_filename/scripts$fastcgi_script_name;
  72. # include Fastcgi_params;
  73. #}
  74. # Deny access to. htaccess files, if Apache ' s document Root
  75. # concurs with Nginx ' s one
  76. #
  77. #location ~/\.ht {
  78. # Deny All;
  79. #}
  80. }
  81. # Another virtual host using mix of ip-, name-, and port-based configuration
  82. #
  83. #server {
  84. # Listen 8000;
  85. # Listen somename:8080;
  86. # server_name somename alias Another.alias;
  87. # location/{
  88. # root HTML;
  89. # index index.html index.htm;
  90. #    }
  91. #}
  92. # HTTPS Server
  93. #
  94. #server {
  95. # Listen 443 SSL;
  96. # server_name localhost;
  97. # ssl_certificate Cert.pem;
  98. # Ssl_certificate_key Cert.key;
  99. # Ssl_session_cache shared:ssl:1m;
  100. # ssl_session_timeout 5m;
  101. # ssl_ciphers high:!anull:! MD5;
  102. # ssl_prefer_server_ciphers on;
  103. # location/{
  104. # root HTML;
  105. # index index.html index.htm;
  106. #    }
  107. #}
  108. }



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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.