I have nginx set up in one server and added RTMP module in the nginx.conf file. I am able to fetch RTMP stream in the same server. But I want to read the stream from another server. I don't how to configure nginx.conf to read the stream from outside of the server.
nginx.conf (server 1):
worker_processes auto;
events {
worker_connections 1024;
}
# RTMP configuration
rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;
# video on demand for flv files
application vod {
play /var/flvs;
}
# video on demand for mp4 files
application vod2 {
play /var/mp4s;
allow publish {server_ip};
allow publish all;
live on;
meta copy;
}
# Define the Application
application show {
live on;
# Turn on HLS
hls on;
hls_path /mnt/hls/;
hls_fragment 3;
hls_playlist_length 60;
# disable consuming the stream from nginx as rtmp
deny play all;
}
}
}
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/;
}
}
}
Trying to read the stream from server 2 using ffmpeg:
ffmpeg -i rtmp://{server1_ip}:1935/vod2/sample.mp4 -c copy test.mp4
Error I am getting when trying to read the stream from another server:
Connection to tcp://{server1_ip}:1935 failed: No route to host
[rtmp @ 0xd68e9c0] Cannot open connection tcp://{server1_ip}:1935
rtmp://{server1_ip}:1935/vod2/sample.mp4: No route to host
Thanks
Regards,
Vishnu
Edited 1 time(s). Last edit at 08/05/2019 01:23PM by Vish427771.