直播搭建

https://blog.csdn.net/boonya/article/details/52210576

https://www.nihaoshijie.com.cn/index.php/archives/615

RTMP 
RTMP是Real Time Messaging Protocol(实时消息传输协议) 
RTMP是一种设计用来进行实时数据通信的网络协议,主要用来在Flash/AIR平台和支持RTMP协议的流媒体/交互服务器之间进行音视频和数据通信。支持该协议的软件包括Adobe Media Server/Ultrant Media Server/red5等。

nginx 
毛子开发的服务器,很强,很轻

nginx-rtmp-module 

相关文档:

https://github.com/arut/nginx-rtmp-module/wiki/

1、下载nginx  rtmp模块

wget https://codeload.github.com/arut/nginx-rtmp-module/zip/master

2、解压zip包

unzip master.zip

3、找到nginx源码包,添加 rtmp模块

 ./configure --add-module=/home/likang/package/nginx-rtmp-module

4、编译 编译安装

 
  1. make

  2. make install

5、添加配置

 
  1. rtmp {

  2.  
  3. server {

  4.  
  5.  
  6. listen 2018; #监听的端口

  7.  
  8. chunk_size 4000; #块大小

  9.  
  10.  
  11. application hls { #rtmp推流请求路径

  12. live on;

  13. hls on;

  14. hls_path /var/www/html/zhibo_rtmp;

  15. hls_fragment 5s;

  16. }

  17. }

  18. }

 
  1. server {

  2. listen 81;

  3. server_name _;

  4. root /var/www/html/zhibo_rtmp;

  5. #charset koi8-r;

  6.  
  7. access_log logs/81.access.log main;

  8. error_log logs/81.error.log;

  9.  
  10. location / {

  11. index index.html index.htm index.php;

  12. autoindex on;

  13. }

  14.  
  15. #error_page 404 /404.html;

  16.  
  17. # redirect server error pages to the static page /50x.html

  18. #

  19. error_page 500 502 503 504 /50x.html;

  20. location = /50x.html {

  21. }

  22.  
  23. # proxy the PHP scripts to Apache listening on 127.0.0.1:80

  24. #

  25. #location ~ \.php$ {

  26. # proxy_pass http://127.0.0.1;

  27. #}

  28.  
  29. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

  30. #

  31. location ~ \.php$ {

  32. fastcgi_pass 127.0.0.1:9000;

  33. fastcgi_index index.php;

  34. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  35. include fastcgi_params;

  36. }

  37.  
  38. # deny access to .htaccess files, if Apache's document root

  39. # concurs with nginx's one

  40. #

  41. #location ~ /\.ht {

  42. # deny all;

  43. #}

  44. }

6、下载obs,用obs软件进行推流

点击设置进入设置页面

串流类型选择: 自定义流媒体服务器

URL: rtmp://47.94.150.11:2018/hls

流秘钥 : test

      自己定义,注意后边在拉直播流的时候 和这里保持一致

7、拉取直播流

 
  1. <!DOCTYPE html>

  2. <html lang="en">

  3. <head>

  4.  
  5. <title>Video.js | HTML5 Video Player</title>

  6.  
  7. <link href="http://vjs.zencdn.net/5.20.1/video-js.css" rel="stylesheet">

  8. <script src="http://vjs.zencdn.net/5.20.1/videojs-ie8.min.js"></script>

  9.  
  10. </head>

  11. <body>

  12.  
  13. <video id="example_video_1" class="video-js vjs-default-skin" controls preload="auto" width="1280" height="720" poster="http://vjs.zencdn.net/v/oceans.png" data-setup="{}">

  14. <!-- <source src="1.mp4" type="video/mp4"> -->

  15. # 这个地方修改为自己的流媒体服务器 如何访问直播流

  16. <source src="http://47.94.150.11:8088/test.m3u8" type='application/x-mpegURL'>

  17. <p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>

  18. </video>

  19.  
  20. <script src="http://vjs.zencdn.net/5.20.1/video.js"></script>

  21. </body>

  22.  
  23. </html>

猜你喜欢

转载自blog.csdn.net/PHPArchitect/article/details/81181959