Usabilidad para mejores practicas del uso de la tecnología.

Primero que todo realizar la instalación y configuración de los siguientes componentes: * Nginx  https://tutoyas.blogspot.com/2019/04/i...

STREAMING NGINX + FFMPEG - MACOSX


Primero que todo realizar la instalación y configuración de los siguientes componentes:

* Nginx  https://tutoyas.blogspot.com/2019/04/instalar-nginx-en-macosx.html
* FFMPEG https://tutoyas.blogspot.com/2019/04/instalar-ffmpeg-macosx.html

Una vez realizado este proceso, continuamos con la edición del archivo de configuración "nginx.conf"

nano /usr/local/etc/nginx/nginx.conf
Nota: Recomiendo realizar copia del archivo de configuración, por si desean volver a la versión anterior.


Vamos a copiar el siguiente fragmento de código, pegarlo antes del http{}

rtmp_auto_push on;
rtmp {
        server {
                listen 1935;
                chunk_size 4096;
                timeout 10s;
                application live {
                        live on;
                        record off;
                }
                application hls {
                        live on;
                        hls on;
                        hls_path /tmp/hls;
                        hls_fragment 5s;
                }
        }
}
Lo siguiente será agregar este fragmento de código dentro de http{}

server {
    listen      8080;
    # This URL provides RTMP statistics in XML
    location /stat {
        rtmp_stat all;
        # Use this stylesheet to view XML as web page
        # in browser
        rtmp_stat_stylesheet stat.xsl;
    }
    location /stat.xsl {
        # XML stylesheet to view RTMP stats.
        # Copy stat.xsl wherever you want
        # and put the full directory path here
        root /usr/local/etc/nginx/rtmp/stat.xsl/;
    }
    location /hls {
        # Serve HLS fragments
        types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
        }
        root /tmp;
        add_header Cache-Control no-cache;
    }
    location /dash {
        # Serve DASH fragments
        root /tmp;
        add_header Cache-Control no-cache;
    }
}
Para el envio del Stream a través de FFMPEG

ffmpeg -re -i input.mp4 -c copy -f flv rtmp://ip_local/hls/live
Reproducir el streaming

http://ip_local:puerto/hls/live/stream.m3u8