arut / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
13.38k stars 3.51k forks source link

Stream without latency? #1268

Open Paolo07700 opened 6 years ago

Paolo07700 commented 6 years ago

Hello, I'm new! I am president and founder of a French association oriented in the audiovisual field. I have a project to make live streaming with several cameras, and computers (video game), for that I have to recover images and its webcams from computers but also the image of their screens. So far I use the solution of NDI over network, but this solution has become pay and I can not find other ways to do this without latency.

How to do ?

Thank you !

lieff commented 6 years ago

I think this issue is not nginx-rtmp related. I've achieve almost zero latency with https://github.com/lieff/minirtmp -> nginx-rtmp -> ffplay -fflags nobuffer [rtmp-url] Note nobuffer option for ffplay player. Without it player introduce 2 second pre-buffer delay.

Paolo07700 commented 6 years ago

Sorry I am a novice, in this area. What should I do with this? And how ?

lieff commented 6 years ago

Since I do not see any issues with latency in nginx-rtmp (except possible network problems), problem probably should be in streamer and/or player.

Paolo07700 commented 6 years ago

But... There are no optimal config for nginx config ? And what is "minirtmp" and the code you showed me ? Sorry I'm very novice to this. I only created a server with a tutorial in the obsproject forum website.

lieff commented 6 years ago

I've use almost default config for test:

worker_processes  1;

events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;

        application myapp {
            live on;

            hls on;
            hls_path ../rtmp/hls/;
            hls_fragment 15s;
        }
    }
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       8080;
        server_name  localhost;

        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root ../rtmp/;
        }

        location /control {
            rtmp_control all;
        }

        location /rtmp-publisher {
            root ../rtmp/test;
        }

        location / {
            root ../rtmp/test/www;
        }

        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
            }
            root ../rtmp/;
            add_header Cache-Control no-cache;

            add_header Access-Control-Allow-Origin *;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
}

"minirtmp" is not a complete application, but you can test nginx-rtmp latency and create streamer/player application with low latency using it.

If you are using obsproject as streamer, you can test if it's part of a problem. Just use ffplay -fflags nobuffer [rtmp-url] as player and test if latency exists. If there no latency in this configuration - player is your problem.