【问题标题】:Receive HLS stream and rebroadcast接收 HLS 流并重播
【发布时间】:2021-01-07 05:50:59
【问题描述】:

我在欧洲有通过 HLS 流式传输的商业流媒体服务器。

http://europe.server/stream1/index.m3u8

现在我在美国的客户由于距离而遇到一些网络问题。

所以我在美国部署了新服务器。我希望它从欧洲服务器接收 HLS 流并响应美国客户。

所以用户可以访问喜欢

http://usa.server/stream1/index.m3u8

它只会是 H265/HEVC,所以 RTMP 是不可能的。我在网上看到的每个教程都是基于 RTMP 的。

我使用了来自https://docs.peer5.com/guides/setting-up-hls-live-streaming-server-using-nginx/ 的以下配置供参考。

worker_processes  auto;
events {
    worker_connections  1024;
}

http {
    sendfile off;
    tcp_nopush on;
    aio on;
    directio 512;
    default_type application/octet-stream;
    
    server {
        listen 8080;

        location / {
            # Disable cache
            add_header 'Cache-Control' 'no-cache';
            
            # CORS setup
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Expose-Headers' 'Content-Length';
            
            # allow CORS preflight requests
            if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' '*';
                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/dash+xml mpd;
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }   
            
            root /mnt/;
        }   
    }
}

【问题讨论】:

    标签: nginx ffmpeg video-streaming streaming http-live-streaming


    【解决方案1】:

    这比看起来要容易得多。

    您不需要任何东西,只需要一个缓存代理服务器。所有的视频工作都已经为您完成了。

    一个类似这样的 Nginx 配置文件就可以了:

    proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=100g 
                 inactive=10m use_temp_path=off;
    
    server {
        location / {
            proxy_cache my_cache;
            proxy_pass http://europe.example.com;
        }
    }
    

    另请参阅:https://www.nginx.com/blog/nginx-caching-guide/#proxy_cache

    另外,我强烈建议使用现有的 CDN,这将提高性能并降低您的维护成本。

    【讨论】:

    【解决方案2】:

    不清楚,问题是什么,但答案是:不,nginx不适合它。

    你仍然需要在美国的视频流服务器,因为如果你想传递 dash + hls,你需要在两个容器中重新打包美国的视频。

    Nginx 会将所有流量发送两次(超过两次),视频流媒体将发送一次。

    【讨论】:

      猜你喜欢
      • 2016-12-10
      • 1970-01-01
      • 1970-01-01
      • 2020-05-15
      • 1970-01-01
      • 2016-09-09
      • 2016-11-08
      • 2023-04-01
      • 1970-01-01
      相关资源
      最近更新 更多