0

I would like to show a RTSP stream in a Web application. I successfully streamed using HLS with the following configuration: RTSP to RTMP:

ffmpeg -stream_loop -1 -re -i "C:\RA\test.m3u8" -acodec aac -vcodec libx264 -f flv rtmp:localhost/live/stream

Nginx (1.7 on windows) configuration

# RTMP configuration
rtmp { 
    server { 
        listen 1935; 
        application live { 
            live on; 
            interleave on;
 
            hls on; 
            hls_path C:\RA\NGINX\hls; 
            hls_fragment 15s; 
        } 
    } 
} 

http {
    sendfile off;
    tcp_nopush on;
    directio 512;
    default_type application/octet-stream;


    server {
        listen 81;


        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 C:\RA\NGINX;
        }
    }
}

I cannot find the documentation or examples related to the WebRTC configuration for NGINX I tried with the socket connection but I don't know how to defined my input stream or what would be the URL to test this...

# RTMP configuration
rtmp { 
    server { 
        listen 1935; 
        application live { 
            live on; 
            
        } 
    } 
} 

http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }
 
    upstream websocket {
        server localhost:8010;
    }
 
    server {
        listen 8020;
        location / {
            proxy_pass http://websocket;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $host;
        }
    }
}
zaius
  • 1
  • 3
  • You need a media server which supports convering RTMP to WebRTC, see this post https://stackoverflow.com/a/75491259/17679565 – Winlin Feb 18 '23 at 05:48

0 Answers0