D
D
DragoN DragoN2018-11-22 09:38:41
linux
DragoN DragoN, 2018-11-22 09:38:41

How to setup video streaming through NGINX using ffmpeg for HTML5?

Trying to set up nginx with nginx-rtmp-module

rtmp {
    server {
        listen 1935;
        chunk_size 4000;

        application dash
        {
                live                    on;
                dash                    on;
                dash_nested             on;
                dash_path               /mnt/dash;
                dash_fragment           3;
                dash_playlist_length    120;
                dash_cleanup            on;
                record                  off;
        }

        application hls
        {
            live on;
            hls on;
            hls_path /mnt/hls/;
            hls_fragment 3;
            hls_playlist_length 60;
        }
    }
}

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

        server
        {
                listen 8080;

                location /dash
                {
                        root            /mnt/;
                        add_header      Cache-Control no-cache;
                }

                location /hls
                {
                        add_header Cache-Control no-cache;
                        add_header 'Access-Control-Allow-Origin' '*' always;
                        add_header 'Access-Control-Expose-Headers' 'Content-Length';

                        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/vnd.apple.mpegurl m3u8;
                                video/mp2t ts;
                        }

                        root /mnt/;
                }
        }
}

I connect the stream to the console:
ffmpeg -i "rtmp://..." -c:v libx264 -profile:v baseline -c:a aac -strict -2 -f flv "rtmp://127.0.0.1/dash/stream"

The VLC media player application plays the stream from the link - http://.../hls/stream.mpd, but browsers do not support this. Is it possible to play the resulting stream in a browser without using third-party libraries and flash? (if not, how?). Well, maybe there are third-party services that convert the stream and output it in the desired format?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
chupasaurus, 2018-11-22
@chupasaurus

Need HLS/DASH player ( for example ).

D
Diman779, 2020-05-04
@Diman779

did you set it up? will you help me?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question