简体   繁体   中英

Can't get dash streaming to work from nginx-rtmp

I'm trying to broadcast a stream from OBS (codec is set x264) to nginx with an rtmp server and then view the stream as mpeg-dash in VLC.

I've set up nginx with the rtmp module and that works. I can stream to nginx and receive the stream via rtmp in VLC. For that I used this URL: rtmp://127.0.0.1/live/stream

This is my config.

 #user  nobody;
worker_processes  1;

error_log  logs/error.log debug;

events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;

        application live {
            live on;
        dash on;
        dash_path /tmp/dash;
        }
    }
}


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

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile off;
    tcp_nopush on;
    aio off;
    directio 512;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    server {
        listen 8080;
    location /dash {
            # Serve DASH fragments
            types {
                application/dash+xml mpd;
                video/mp4 mp4;
            }
            root /tmp;
            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;
            }
        }
    }
}

I can see the stream.mpd in the file explorer, but VLC always says can't open source. I've tried both URLs: http://127.0.0.1/tmp/dash/stream.mpd and http://127.0.0.1/dash/stream.mpd , but both didn't work.

I also tried it with HLS, but I couldn't get this to work either.

To avoid having troubles with file privileges, I set the whole folder to chmod 777.

Any ideas what could be wrong or what I could try? Thank you

I solved it, sort of...

I used the config from here: HTML5 live streaming

I had to change some things in the file (http-tag was missing as an example) but then it worked with HLS. Turns out it doesn't really make a difference if I'm using MPEG-DASH or HLS, so I'm fine with it.

Another thing I found out, is that I always tried it without defining the port. For RTMP this made no problems since I could use the standard port. But on http I had to use port 8080 since 80 was already in use. But in VLC I didn't think to define the port.

Now it works for me;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM