gpt4 book ai didi

nginx - 接收 HLS 流并重播

转载 作者:行者123 更新时间:2023-12-04 23:21:57 28 4
gpt4 key购买 nike

我在欧洲有通过 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 配置文件就可以了:

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,这将提高性能并降低您的维护成本。

关于nginx - 接收 HLS 流并重播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63987108/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com