Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1062997
  • 博文数量: 77
  • 博客积分: 821
  • 博客等级: 军士长
  • 技术积分: 1905
  • 用 户 组: 普通用户
  • 注册时间: 2011-10-23 16:17
个人简介

学校:上海交通大学软件工程 学历:硕士 行业:从事流媒体移动开发 QQ: 412595942 邮箱:yiikai1987910@gmail.com

文章分类

全部博文(77)

文章存档

2016年(4)

2015年(15)

2014年(16)

2013年(12)

2012年(21)

2011年(9)

分类: C/C++

2015-10-09 17:42:25

     今天尝试了下用nginx搭建hls直播服务
    进行rtmp推流到nginx服务器需要nginx-rtmp-module, 编译nginx的时候把它加入即可
    最重要的是配置nginx.conf 配置文件
    我的配置如下:
    

点击(此处)折叠或打开

  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 /srv/nginxhls/app;
  28.          hls_path /mnt/hgfs/D/C++ALG/TSParser/hlsCarmeaLive;
  29.            hls_fragment 10s;




  30.        }
  31.     }
  32. }


  33. http {
  34.     server {
  35.         listen 80;


  36.         location /stat {
  37.             rtmp_stat all;
  38.             rtmp_stat_stylesheet stat.xsl;
  39.         }


  40.         location /stat.xsl {
  41.             root <path-to-nginx-rtmp-module>;
  42.         }


  43.         location /control {
  44.             rtmp_control all;
  45.         }


  46.         #location /publish {
  47.         # return 201;
  48.         #}


  49.         #location /play {
  50.         # return 202;
  51.         #}


  52.         #location /record_done {
  53.         # return 203;
  54.         #}


  55.         location /rtmp-publisher {
  56.             root <path-to-nginx-rtmp-module>/test;
  57.         }


  58.         location /hls {
  59.            #server hls fragments
  60.            types{
  61.              application/vnd.apple.mpegurl m3u8;
  62.               video/mp2t ts;
  63.            }
  64.         alias /mnt/hgfs/D/C++ALG/TSParser/hlsCarmeaLive;
  65.         #/srv/nginxhls/app;
  66.         expires -1;
  67.         }


  68.         location / {
  69.         return 404;    
  70.         }


  71.     }
  72. }
     配置好以后,nginx -c nginx.conf  启动nginx
    
    然后就可以进行推流的工作了,用ffmepg抓取摄像头视频数据
    

点击(此处)折叠或打开

  1. ffmpeg.exe -f dshow -i video="USB2.0 HD UVC WebCam" -vcodec libx264 -pix_fmt yuv420p -f flv rtmp://10.2.68.133/hls/test1
    可以看到,数据被推倒了服务器上,并且我在rtmp的块这种设定了hls的切片功能,所以推上去的流会被切成hls的形式
   这样就可以进行hls的访问了
   在播放器上运行link:
   

点击(此处)折叠或打开

  1. http://10.2.68.133/hls/test1.m3u8
  可以看到有视频输出了


 延迟还是比较大的,继续研究优化。
阅读(9623) | 评论(0) | 转发(0) |
1

上一篇: SSL 以及 openssl使用

下一篇:VIM 配置

给主人留下些什么吧!~~