当前位置:   article > 正文

window系统:nginx(nginx-rtmp-module模块)实现rtmp服务器_windows编译nginx rtmp

windows编译nginx rtmp

下载

下面链接直接点击下载,下载的就是包含rtmp服务器相关功能的,只不过需要配置下

Index of /download/ (ecsds.eu)

 

nginx 1.7.11.3 Gryphon.zip

直接点击额下面的连接即可下载

http://nginx-win.ecsds.eu/download/nginx%201.7.11.3%20Gryphon.zip

配置

需要把nginx-win.conf配置文件的名称修改为nginx.conf,不然启动nginx.exe的时候会报错

查看日志如下

 

修改配置文件

配置文件路径为conf目录下的nginx-win.conf配置文件

新增的部分我做了标记

  1. #user nobody;
  2. # multiple workers works !
  3. worker_processes 2;
  4. #error_log logs/error.log;
  5. #error_log logs/error.log notice;
  6. #error_log logs/error.log info;
  7. #pid logs/nginx.pid;
  8. events {
  9. worker_connections 8192;
  10. # max value 32768, nginx recycling connections+registry optimization =
  11. # this.value * 20 = max concurrent connections currently tested with one worker
  12. # C1000K should be possible depending there is enough ram/cpu power
  13. # multi_accept on;
  14. }
  15. # 新增-----
  16. rtmp {
  17. server {
  18. listen 1935;
  19. chunk_size 4000;
  20. application live {
  21. live on;
  22. }
  23. }
  24. }
  25. # 新增-----
  26. http {
  27. #include /nginx/conf/naxsi_core.rules;
  28. include mime.types;
  29. default_type application/octet-stream;
  30. #log_format main '$remote_addr:$remote_port - $remote_user [$time_local] "$request" '
  31. # '$status $body_bytes_sent "$http_referer" '
  32. # '"$http_user_agent" "$http_x_forwarded_for"';
  33. #access_log logs/access.log main;
  34. # # loadbalancing PHP
  35. # upstream myLoadBalancer {
  36. # server 127.0.0.1:9001 weight=1 fail_timeout=5;
  37. # server 127.0.0.1:9002 weight=1 fail_timeout=5;
  38. # server 127.0.0.1:9003 weight=1 fail_timeout=5;
  39. # server 127.0.0.1:9004 weight=1 fail_timeout=5;
  40. # server 127.0.0.1:9005 weight=1 fail_timeout=5;
  41. # server 127.0.0.1:9006 weight=1 fail_timeout=5;
  42. # server 127.0.0.1:9007 weight=1 fail_timeout=5;
  43. # server 127.0.0.1:9008 weight=1 fail_timeout=5;
  44. # server 127.0.0.1:9009 weight=1 fail_timeout=5;
  45. # server 127.0.0.1:9010 weight=1 fail_timeout=5;
  46. # least_conn;
  47. # }
  48. sendfile off;
  49. #tcp_nopush on;
  50. server_names_hash_bucket_size 128;
  51. ## Start: Timeouts ##
  52. client_body_timeout 10;
  53. client_header_timeout 10;
  54. keepalive_timeout 30;
  55. send_timeout 10;
  56. keepalive_requests 10;
  57. ## End: Timeouts ##
  58. #gzip on;
  59. server {
  60. listen 80;
  61. server_name localhost;
  62. # 新增-----
  63. location /stat {
  64. rtmp_stat all;
  65. rtmp_stat_stylesheet stat.xsl;
  66. }
  67. location /stat.xsl {
  68. root nginx-rtmp-module/;
  69. }
  70. location /control {
  71. rtmp_control all;
  72. }
  73. # 新增-----
  74. #charset koi8-r;
  75. #access_log logs/host.access.log main;
  76. ## Caching Static Files, put before first location
  77. #location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  78. # expires 14d;
  79. # add_header Vary Accept-Encoding;
  80. #}
  81. # For Naxsi remove the single # line for learn mode, or the ## lines for full WAF mode
  82. location / {
  83. #include /nginx/conf/mysite.rules; # see also http block naxsi include line
  84. ##SecRulesEnabled;
  85. ##DeniedUrl "/RequestDenied";
  86. ##CheckRule "$SQL >= 8" BLOCK;
  87. ##CheckRule "$RFI >= 8" BLOCK;
  88. ##CheckRule "$TRAVERSAL >= 4" BLOCK;
  89. ##CheckRule "$XSS >= 8" BLOCK;
  90. root html;
  91. index index.html index.htm;
  92. }
  93. # For Naxsi remove the ## lines for full WAF mode, redirect location block used by naxsi
  94. ##location /RequestDenied {
  95. ## return 412;
  96. ##}
  97. ## Lua examples !
  98. # location /robots.txt {
  99. # rewrite_by_lua '
  100. # if ngx.var.http_host ~= "localhost" then
  101. # return ngx.exec("/robots_disallow.txt");
  102. # end
  103. # ';
  104. # }
  105. #error_page 404 /404.html;
  106. # redirect server error pages to the static page /50x.html
  107. #
  108. error_page 500 502 503 504 /50x.html;
  109. location = /50x.html {
  110. root html;
  111. }
  112. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  113. #
  114. #location ~ \.php$ {
  115. # proxy_pass http://127.0.0.1;
  116. #}
  117. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  118. #
  119. #location ~ \.php$ {
  120. # root html;
  121. # fastcgi_pass 127.0.0.1:9000; # single backend process
  122. # fastcgi_pass myLoadBalancer; # or multiple, see example above
  123. # fastcgi_index index.php;
  124. # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  125. # include fastcgi_params;
  126. #}
  127. # deny access to .htaccess files, if Apache's document root
  128. # concurs with nginx's one
  129. #
  130. #location ~ /\.ht {
  131. # deny all;
  132. #}
  133. }
  134. # another virtual host using mix of IP-, name-, and port-based configuration
  135. #
  136. #server {
  137. # listen 8000;
  138. # listen somename:8080;
  139. # server_name somename alias another.alias;
  140. # location / {
  141. # root html;
  142. # index index.html index.htm;
  143. # }
  144. #}
  145. # HTTPS server
  146. #
  147. #server {
  148. # listen 443 ssl spdy;
  149. # server_name localhost;
  150. # ssl on;
  151. # ssl_certificate cert.pem;
  152. # ssl_certificate_key cert.key;
  153. # ssl_session_timeout 5m;
  154. # ssl_prefer_server_ciphers On;
  155. # ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  156. # ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:ECDH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!eNULL:!MD5:!DSS:!EXP:!ADH:!LOW:!MEDIUM;
  157. # location / {
  158. # root html;
  159. # index index.html index.htm;
  160. # }
  161. #}
  162. }

启动

  1. #关闭nginx服务命令
  2. nginx -s stop -c conf/nginx-win.conf
  3. #启动nginx服务命令
  4. start nginx -c conf/nginx-win.conf

测试方案1

利用ffmpeg推流

ffmpeg -f dshow -i video="USB2.0 Camera"  -vcodec   libx264 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://localhost:1935/live/123

利用vlc查看rtmp流

测试方案2

利用obs推流

设置推流地址

 选择直播--服务(选择自定义)--服务器输入rtmp地址--推流码输入流名称即可,我输入的是123

添加窗体

 选择时钟的页面,点击确认

 开始直播

 利用vlc查看视频

媒体--打开网络串流

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/195963
推荐阅读
相关标签
  

闽ICP备14008679号