我一直在做一个项目,在这个项目中,我需要能够动态地推送到其他两个或三个频道。我测试了几种场景,最后一次尝试如下:
流服务器
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内容中读取。我尝试过使用节点媒体服务器和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 *;
}
}
}如果您知道任何其他选择,请让我知道或有任何其他建议,谢谢
发布于 2022-08-22 02:55:56
你想这样做吗?
Client -----> Nginx -------> Server
(Stream 1/2/3) (Stream 2)您不应该让另一台服务器从Nginx读取Stream 2,整数您应该使用FFmpeg作为客户端这样做:
Client -----> Nginx -----> FFmpeg --> Server
(Stream 1/2/3) (Stream 2)要做到这一点,请像这样运行命令:
ffmpeg -f flv -i rtmp://ip/live/stream2 -c copy -f flv rtmp://server/live/stream2因此,您可以将任何流从Nginx读取到另一台服务器。
如果您希望
Server执行此操作,则可以使用SRS/Ingest,该SRS/Ingest叉一个FFmpeg进程将流拉到SRS
发布于 2022-09-05 09:32:19
@Winlin for Nginx上面提到的解决方案将有效,而且由于问题是关于Nginx I的,所以将其标记为批准的答案,
一般来说,ffmpeg是关键,我也尝试了,而ffmpeg是推荐的方法。
指向包的链接:https://github.com/illuspas/Node-Media-Server
我的设置的样例配置:
const config = {
rtmp: {
port: 1937,
chunk_size: 60000,
gop_cache: true,
ping: 30,
ping_timeout: 60,
},
relay: {
ffmpeg: "/bin/ffmpeg",
tasks: [
{
name: "XXXXX",
app: "live",
mode: "static",
edge: "rtmp://rtmp_server:1935/live/test", // my other server
},
{
app: "live",
name: "XXXXX",
mode: "push",
edge: "rtmp://live.twitch.tv/app", // twitch server
},
],
},
};https://stackoverflow.com/questions/73050367
复制相似问题