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...


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

Nota: Antes de realizar la instalación del ffmpeg tener instalado el Blackmagic Desktop Vídeo, correspondiente a su tarjeta Decklink P...



Nota: Antes de realizar la instalación del ffmpeg tener instalado el Blackmagic Desktop Vídeo, correspondiente a su tarjeta Decklink
Para empezar se debe realizar el siguiente proceso:

1.) instalar librerias para el ffmpeg
brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 x265 xvid nasm
2.) Descargar y clonar versión del ffmpeg
git clone http://source.ffmpeg.org/git/ffmpeg.git ffmpeg
3.) Ingresar a la carpeta ffmpeg
cd ffmpeg
4.) Ahora compilar el ffmpeg, tener en cuenta la ruta de instalación de su sistema operativo mac, verificar con el finder la raíz
./configure  --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid --samples=fate-suite --enable-decklink --enable-openssl --extra-cflags="-I$RUTADISCO/usr/local/include/" --extra-ldflags="-L$RUTADISCO/usr/local/lib/"
5.) Realizar el make
make
6.) Realizar instalar ffmpeg
make install 
7.) Verificar ffmpeg la lista de dispositivos Decklink instalados en su macOSX
ffmpeg -f decklink -list_devices 1 -i dummy

Si al ejecutar el siguiente comando, aparece error brew tap homebre/nginx 1. Instalar brew xcode-select –install 2.Una vez...





Si al ejecutar el siguiente comando, aparece error

brew tap homebre/nginx

1. Instalar brew

xcode-select –install

2.Una vez terminada la instalación ingresar el siguiente comando:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3. Ingresar este comando

brew tap homebrew/nginx

Nota: Si arroja error al ingresarlo, usar el siguiente comando

brew tap denji/nginx

4. Luego este

brew options nginx-full

5. Luego este

brew info nginx-full

6. Finalmente este

brew install nginx-full --with-rtmp-module --with-debug

7. Para editar el archivo de nginx.conf

nano /usr/local/etc/nginx/nginx.conf

8. Para ponerlo en funcionamiento

sudo chown root:wheel /usr/local/opt/nginx-full/bin/nginx

9. Para ponerlo en funcionamiento

sudo chmod u+s /usr/local/opt/nginx-full/bin/nginx

10. Luego iniciamos el servicio:

/usr/local/opt/nginx-full/bin/nginx

11. Revisar el archivo de configuración para confirmar cual es el puerto de escucha 80, 8000 o el 8080.

nano /usr/local/etc/nginx/nginx.conf

12. Confirmar acceso a través del navegador o explorador de su preferencia.

http://localhost:8080 - http://localhost:80

1. COMPILAR FFMPEG OSX A TRAVÉS DEL TERMINAL $ xcode-select --install 2. Instalar brew con el siguiente comando ruby -e "$(cur...


1. COMPILAR FFMPEG OSX A TRAVÉS DEL TERMINAL
$ xcode-select --install
2. Instalar brew con el siguiente comando
 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
3. Instalar las siguientes librerías
brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 x265 xvid nasm openssl pkg-config
4. Descargar la ultima versión del ffmpeg
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
5. Ingresar a la carpeta del ffmpeg descargado anteriormente
cd ffmpeg
6. Lanzar ./configure
./configure  --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid --samples=fate-suite
7. Lanzar comando make, preferiblemente como usuario root
make
8. Lanzar comando make install, preferiblemente como usuario root
make install
9. Verificar version y rutas del ffmpeg
ffmpeg --verificar versión con las librerías compiladas.
/usr/local/bin/ --Ruta del ffmpeg para poder ejecutarlo a través del servidor Nginx
10. Listo disfrutar el ffmpeg

Previos en OSX, si no tiene instalado el " brew " instalarlo de la siguiente forma ruby -e "$(curl -fsSL https://raw....



Previos en OSX, si no tiene instalado el " brew " instalarlo de la siguiente forma

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Instalador C y GCC

install build-essential -y

Descargar librerias necesarias
  • pcre - versión descargada 4.4 - 8.40
  • zlib - versión descargada 1.1.3 - 1.2.11
  • openssl -versión descargada 1.0.2 - 1.1.0

wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz && tar xzvf pcre-8.40.tar.gz


wget http://www.zlib.net/zlib-1.2.11.tar.gz && tar xzvf zlib-1.2.11.tar.gz


wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz && tar xzvf openssl-1.1.0f.tar.gz

1. Descargar NGINX

wget http://nginx.org/download/nginx-1.13.10.tar.gz

2. Descargar modulo rtmp

wget https://github.com/arut/nginx-rtmp-module/archive/master.zip

3. Descomprimir nginx

tar zxpvf nginx-1.13.10.tar.gz

4. Descomprimir modulo rtmp con herramienta Unzip

Nota: Si no tiene instalado unzip lo puede instalar en OSX brew install unzip, en LINUX apt-get install unzip

Unzip master.zip

5. Ingresar a la carpeta nginx

cd nginx-1.13.10

6. Lanzar el ./configure

Nota: Revisar la ruta de ubicación del modulo RTMP para que se agregue correctamente al lanzar el ./configure

./configure 
   --add-module=/RUTA-DE-UBICACION/nginx-rtmp-module-master/ \
   --prefix=/usr/local/nginx  \
            --sbin-path=/usr/local/nginx/sbin/nginx \
            --modules-path=/usr/lib/nginx/modules \
            --conf-path=/usr/local/nginx/conf/nginx.conf \
            --error-log-path=/var/log/nginx/error.log \
            --http-log-path=/var/log/nginx/access.log \
            --pid-path=/usr/local/var/run/nginx.pid \
            --lock-path=/usr/local/var/lock/nginx.lock \
            --user=www-data \
            --group=www-data \
            --build=Ubuntu \
            --http-client-body-temp-path=/var/lib/nginx/body \
            --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
            --http-proxy-temp-path=/var/lib/nginx/proxy \
            --http-scgi-temp-path=/var/lib/nginx/scgi \
            --http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
            --with-openssl=/RUTA-DE-UBICACION/openssl-1.1.0f \
            --with-openssl-opt=enable-ec_nistp_64_gcc_128 \
            --with-openssl-opt=no-nextprotoneg \
            --with-openssl-opt=no-weak-ssl-ciphers \
            --with-openssl-opt=no-ssl3 \
            --with-pcre=/RUTA-DE-UBICACION/pcre-8.40 \
            --with-pcre-jit \
            --with-zlib=/RUTA-DE-UBICACION/zlib-1.2.11 \
            --with-compat \
            --with-file-aio \
            --with-threads \
            --with-http_addition_module \
            --with-http_auth_request_module \
            --with-http_dav_module \
            --with-http_flv_module \
            --with-http_gunzip_module \
            --with-http_gzip_static_module \
            --with-http_mp4_module \
            --with-http_random_index_module \
            --with-http_realip_module \
            --with-http_slice_module \
            --with-http_ssl_module \
            --with-http_sub_module \
            --with-http_stub_status_module \
            --with-http_v2_module \
            --with-http_secure_link_module \
            --with-mail \
            --with-mail_ssl_module \
            --with-stream \
            --with-stream_realip_module \
            --with-stream_ssl_module \
            --with-stream_ssl_preread_module \
            --with-debug \
            --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' \
            --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now'

7. Ahora lanzar el comando make

make

8. Seguido el comando make install

make install

Aquí les dejo un vídeo de como realizar Streaming en formato HLS en S.O Ubuntu Server 16.04





Aquí les dejo un vídeo de como realizar Streaming en formato HLS en S.O Ubuntu Server 16.04



Este tutorial te enseñara a como utilizar video.js como reproductor de una fuente de vídeo HLS, publicado a través de un servidor ...




Este tutorial te enseñara a como utilizar video.js como reproductor de una fuente de vídeo HLS, publicado a través de un servidor Nginx

1. Lo primero tener ya instalado y configurado el servidor Nginx con el modulo RTMP
2. El archivo de Nginx.conf debe tener la siguiente configuración:


#user  nobody;
worker_processes  1;
error_log  logs/rtmp_error.log debug;
pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    server {
        listen       8080;
        server_name  localhost;

        location /hls {
            # Serve HLS fragments

            # 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/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            root /tmp;
            add_header Cache-Control no-cache;
        }
    }
}

rtmp {
        server {
                listen 1935;
                chunk_size 8192;

                application hls {
                        live on;
                        meta copy;
                        hls on;
                        hls_path /tmp/hls;
        }

    }

}

3. Una vez que este guardado el archivo Nginx.conf, iniciar el servidor.
4. Lo siguiente sería enviar la fuente o emitir el Streaming (Obs, ffmpeg y Xsplit etc...)
rtmp://ip_servidor/hls/live


5. Realizado este proceso simplemente se puede crear una página en html5 con la siguiente información:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Live Streaming</title>
    <link href="https://vjs.zencdn.net/7.3.0/video-js.css" rel="stylesheet">
    <script src="https://vjs.zencdn.net/ie8/ie8-version/videojs-ie8.min.js"></script>
</head>
<body>
<video id="player" class="video-js vjs-default-skin" height="360" width="640" controls preload="none">
    <source src="http://ip-servidor:8080/hls/live.m3u8" type="application/x-mpegURL" />
</video>
<script>
    var player = videojs('#player');
</script>
</body>
</html>



Nota: Para esta practica solo se utilizo el formato .m3u8, por lo tanto los únicos navegadores que soportan ese formato nativamente son Safari y Microsoft Egde, si desea usar webm y mp4, respectivamente deberá configurar el archivo nginx.conf con salida de ese tipo de formatos.