HLS没有传输声音

时间:2016-10-31 03:53:44

标签: video nginx rtmp live-streaming hls

nginx模块配置了nginx-rtmp-module。

user www-data;
worker_processes  1;
events {
    multi_accept on;
    worker_connections  1024;
}
rtmp
{
    server
    {
        listen 1935;
         chunk_size 4000;

        application hls {
            live on;
            hls on;
            hls_path /usr/html/***.**/hls;
            hls_fragment 3;
            hls_playlist_length 60;

        }
        application live
        {
            live on;
        }

    }
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
     tcp_nopush on;
  tcp_nodelay on;
  client_max_body_size 100M;
  types_hash_max_size 2048;
index           index.php index.html index.htm;
  server_names_hash_bucket_size 64; 
  gzip on;
  gzip_disable "msie6";

  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 5;
  gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

 server {
  listen 80;
  server_name ***.**;
  error_log on;
  access_log on;
  error_log     /var/log/nginx/e.log error;
  access_log    /var/log/nginx/a.log; 
index           index.php index.html index.htm;
  location / {
    try_files $uri $uri/ =404; 
root /usr/html/***.**;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
  }
 location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/phpfpm.sock;
        fastcgi_index  index.php;
        include        fastcgi_params;
        #fastcgi_pass   127.0.0.1:9000;

        fastcgi_param  SCRIPT_FILENAME  $document_root/***.**/$fastcgi_script_name;

}

    location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }  
         location /stat.xsl {
            root    /usr/html/***.**;
        }
        location /hls {  
        add_header Cache-Control no-cache;
        add_header 'Access-Control-Allow-Origin' '*' always;
        add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
        add_header 'Access-Control-Allow-Headers' 'Range';
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Headers' 'Range';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            return 204;
        }
           types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
        } 
            alias /usr/html/***.**/hls;   
        } 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root    /usr/html/***.**;
        }  

}
}

结果:

  • Rtmp在不同的浏览器中表现良好
  • 列表项目RTMP无法在移动设备上播放
  • 列表项目视频无法播放HLS的计算机浏览器
  • 列出项目hls,用于在手机上播放的视频精彩
  • 列表项HLS未传输音频

我做错了什么?

0 个答案:

没有答案