Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nginx流媒体直播和质量转换器_Nginx_Video_Streaming - Fatal编程技术网

Nginx流媒体直播和质量转换器

Nginx流媒体直播和质量转换器,nginx,video,streaming,Nginx,Video,Streaming,我已经在ubuntu服务器16.04下创建了一个nginx流媒体服务器 所有的工作都很好,实时流媒体RTMP和HLS就像一个魔咒一样工作,播放wircas不能正常连接到RTMP服务器,并且可以在web播放器上显示流量 现在我想在播放器上显示一个视频质量转换器 我使用比特莫文播放器 我曾尝试使用Ffmpeg进行转码,但在播放器上没有质量转换器 这是我的nginx配置文件 worker_processes auto; error_log logs/error.log debug; events {

我已经在ubuntu服务器16.04下创建了一个nginx流媒体服务器 所有的工作都很好,实时流媒体RTMP和HLS就像一个魔咒一样工作,播放wircas不能正常连接到RTMP服务器,并且可以在web播放器上显示流量

现在我想在播放器上显示一个视频质量转换器 我使用比特莫文播放器 我曾尝试使用Ffmpeg进行转码,但在播放器上没有质量转换器

这是我的nginx配置文件

worker_processes auto;
error_log logs/error.log debug;
events {

    worker_connections 1024;
}
rtmp {

    server {

        listen 1935;
        allow play all;
        chunk_size 4000;

        #hls - "live" full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments
        application live {

            allow play all;
            live on;
            meta on;
            #record all;
            #record_path /video_recordings;
            #record_unique off;
            hls on;
            hls_nested on;
            hls_path /HLS/live;
            hls_fragment 10s;
            hls_type live;
            allow publish 127.0.0.1;
            #allow publish 192.168.2.0/24;
            #allow publish 192.168.22.0/24;
            #allow publish 70.62.116.192/27;
            #deny publish all;
            allow publish all;
            # create the sampled HLS streams
            # 240p - low def 288kbps / 480p standard def 448kbps / 720p hi def at 2048kbps / source
            # create 3 other stored HLS variants in vod
            exec ffmpeg -i rtmp://localhost:1935/$app/$name
            -c:v libx264 -acodec copy -b:v 256k -vf "scale=480:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -g 60 -hls_list_size 0 -f flv rtmp://localhost:1935/savehls/$name_low
            -c:v libx264 -acodec copy -b:v 768k -vf "scale=720:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -g 60 -hls_list_size 0 -f flv rtmp://localhost:1935/savehls/$name_mid
            -c:v libx264 -acodec copy -b:v 1920k -vf "scale=1080:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -g 60 -hls_list_size 0 -f flv rtmp://localhost:1935/savehls/$name_high;

            # create local mp4 archive
            exec ffmpeg -i rtmp://localhost:1935/$app/$name -c:v libx264 -vprofile baseline -acodec aac -strict -2 -f mp4 /video_recordings/$name.mp4;
            # exec ffmpeg -y -i $path -c:v libx264 -vprofile baseline -acodec aac -strict -2 -f mp4 $dirname/$name.mp4;
        }

        # hls converted streams
        # - streams for mobile live and archives the HLS video manifest and video fragments
        application savehls {

            allow play all;
            live on;
            hls on;
            hls_nested on;
            hls_path /HLS/streams;
            hls_fragment 10s;
            hls_variant _low BANDWIDTH=288000; # Low bitrate, sub-SD resolution
            hls_variant _mid BANDWIDTH=448000; # Medium bitrate, SD resolution
            hls_variant _high BANDWIDTH=2048000; # High bitrate, HD 720p resolution
            # turn off clean-up, if we want these to stay
            # - note: the ts files will only have the last 5 seconds or so of ts files. so doing this is of limited help
            hls_cleanup on;
        }

        #allows you to play your recordings of your live streams using a URL like "rtmp://my-ip:1935/vod/filename.flv"
        #application vod {
        #play /video_recordings;
        #}

    }
}

http {

    include /etc/nginx/geoip/*.http.scope;
    include /usr/local/nginx/conf/mime.types;
    sendfile off;
    tcp_nopush on;
    directio 512;
    # geoip variables/filters
    #geoip_country /usr/share/GeoIP/GeoIP.dat;
    vhost_traffic_status_zone;
    map $http_user_agent $filter_user_agent {

        default 'unknown';
        ~iPhone ios;
        ~Android android;
        ~(MSIE|Mozilla) windows;
    }
    vhost_traffic_status_filter_by_set_key $filter_user_agent agent::*;
    #vhost_traffic_status_filter_by_set_key $geoip_country_code country::*;

    server {

        listen 80;
        server_name xxx.160.78.xx;

        # stats variables
        #vhost_traffic_status_filter_by_set_key $geoip_country_code country::$server_name;
        vhost_traffic_status_filter_by_set_key $filter_user_agent agent::$server_name;

        # vod caches
        vod_metadata_cache metadata_cache 2048m;
        vod_response_cache response_cache 128m;

        # vod variables
        open_file_cache max=1000 inactive=5m;
        open_file_cache_valid 2m;
        open_file_cache_min_uses 1;
        open_file_cache_errors on;
        aio on;
        # vod share
        location /vodhls/ {

            vod hls;
            vod_mode local;
            vod_align_segments_to_key_frames on;
            alias /video_recordings/;
            gzip on;
            gzip_types application/vnd.apple.mpegurl;
            vod_last_modified_types *;
            add_header Access-Control-Allow-Headers 'origin,range,accept-encoding,referrer';
            add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
            add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
            add_header Access-Control-Allow-Origin '*';
            expires 100d;
            add_header Last-Modified "Sun, 19 Nov 2000 08:52:00 GMT";
        }

        # hls - http-location for full-resolution desktops
        # - "http://my-ip/live/my-stream-key/index.m3u8"
        location /live {

            default_type application/octet-stream;
            types {

                application/dash+xml mpd;
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }

            alias /HLS/live;
            # disable cache and add CORS headers
            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';

            # allow CORS preflight requests
            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;
            }
        }

        # HLS - create the http-location for mobile-device live streams and hls stream archives
        # - "http://my-ip/mobile/my-stream-key/index.m3u8"
        location /streams {

            types {

                application/dash+xml mpd;
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            alias /HLS/streams;
            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';
        }

        # creates http access to vod folder
        location /vod {

            alias /video_recordings;
            index index.html;
            add_header Cache-Control no-cache;
            include /usr/local/nginx/conf/mime.types;
        }

        #allows us to see how stats on viewers on our Nginx site using a URL like: "http://my-ip/stats"
        location /mwstats {

            rtmp_stat all;
            rtmp_stat_stylesheet /stat.xsl;
            stub_status;
            access_log off;
        }

        location /vod_status {

            vod_status;
            access_log off;
        }

        location /mwhoststats {

            vhost_traffic_status_display;
            vhost_traffic_status_display_format html;
        }

        #allows us to host some webpages which can show our videos: "http://my-ip/my-page.html"
        #location / {
        #default_type text/html;
        #include /usr/local/nginx/conf/mime.types;
        #include /usr/local/nginx/conf/cors.conf;
        #root html;
        #index index.html index.htm;

        #}
    }
}