【发布时间】:2022-08-22 10:55:56
【问题描述】:
我一直在从事一个需要能够动态推送到 2 或 3 个其他频道的项目。我测试了几个场景,我的最后一次尝试如下:
流服务器
worker_processes auto;
rtmp_auto_push on;
events {}
rtmp {
server {
listen 1935; # Listen on standard RTMP port
application live {
live on;
hls on;
hls_path /www/tmp/hls;
hls_fragment 10s; # default is 5s
hls_playlist_length 5m; # default is 30s
# once playlist length is reached it deletes the oldest fragments
# authentication
# on_publish => some other server
# on_done => some other server
}
}
}
http {
server {
listen 8080;
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
application/octet-stream ts;
}
root /www/tmp;
add_header Cache-Control no-cache;
# To avoid issues with cross-domain HTTP requests (e.g. during development)
add_header Access-Control-Allow-Origin *;
}
}
}
然后强制另一台服务器读取该服务器创建的 hls 内容。我尝试使用 node-media-server 和 nginx,但都没有真正的解决方案,这是我对 nginx 的尝试:
events {}
rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;
# ping 30s;
# notify_method get;
# This application is to accept incoming stream
application live {
live on; # Allows live input
deny play all; # disable consuming the stream from nginx as rtmp
hls on; # Enable HTTP Live Streaming
hls_fragment 3;
hls_playlist_length 10;
hls_path /www/tmp/hls; # hls fragments path
# MPEG-DASH
dash on;
dash_path /mnt/dash/; # dash fragments path
dash_fragment 3;
dash_playlist_length 10;
push => another rtmp server;
}
}
}
http {
server {
listen 8080;
location / {
root /www;
}
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
application/octet-stream ts;
}
root /tmp;
add_header Cache-Control no-cache;
# To avoid issues with cross-domain HTTP requests (e.g. during development)
add_header Access-Control-Allow-Origin *;
}
}
}
如果您知道任何其他选择,请告诉我或有任何其他建议,谢谢
标签: nginx stream http-live-streaming rtmp node-media-server