{"id":2205,"date":"2020-01-23T19:21:22","date_gmt":"2020-01-24T01:21:22","guid":{"rendered":"https:\/\/www.lastdragon.net\/?p=2205"},"modified":"2023-02-21T19:13:20","modified_gmt":"2023-02-22T01:13:20","slug":"servidor-de-streaming-rtmp-con-nginx-y-ffmpeg-pc-o-raspberry","status":"publish","type":"post","link":"https:\/\/www.lastdragon.net\/?p=2205","title":{"rendered":"Servidor de streaming ( rtmp ) con Nginx y ffmpeg ( PC o Raspberry )"},"content":{"rendered":"\n<p><strong>\u00bf Para que ?<\/strong><\/p>\n\n\n\n<p>Puedes tener un sistema de TV interno en lugares aislados como plataformas marinas, donde puedes usar la infraestructura de red para transportar video.<\/p>\n\n\n\n<p><strong>Requerimientos<\/strong> <\/p>\n\n\n\n<p>El codec H264 para incluirlo en ffmpeg<br \/>\nNginx con el parche del modulo de rtmp para incluirlo en el Nginx<\/p>\n\n\n\n<p>Todo sera instalado desde sus fuentes, aunque sera instalado desde un centos 8 , esto deberia funcionar en cualquier GNU\/Linux que cumpla con las librerias y el compilador GNU C<\/p>\n\n\n\n<p><strong>Compilar el codec H264<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>git clone &#8211;depth 1 https:\/\/code.videolan.org\/videolan\/x264.git<\/p>\n\n\n\n<p> cd x264<\/p>\n\n\n\n<p> En PC .\/configure &#8211;enable-static &#8211;disable-opencl &#8211;disable-asm<\/p>\n\n\n\n<p> En Raspberry .\/configure &#8211;host=arm-unknown-linux-gnueabi &#8211;enable-static \u2013disable-opencl<\/p>\n\n\n\n<p> make<\/p>\n\n\n\n<p> make install<\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Compilar ffmpeg usando el codec previamente compilado H264<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite>git clone git:\/\/source.ffmpeg.org\/ffmpeg \u2013depth=1<br \/> cd ffmpeg\/<br \/> En PC .\/configure &#8211;target-os=linux &#8211;enable-gpl &#8211;enable-libx264 &#8211;enable-nonfree &#8211;disable-x86asm<br \/> En Raspberry .\/configure &#8211;arch=armel &#8211;target-os=linux &#8211;enable-gpl &#8211;enable-libx264 \u2013enable-nonfree<br \/> make<br \/> make install<\/cite><\/blockquote>\n\n\n\n<p><strong>Compilar nginx con el modulo rtmp<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>git clone git:\/\/github.com\/arut\/nginx-rtmp-module.git<\/p>\n\n\n\n<p>wget &#8220;http:\/\/nginx.org\/download\/nginx-1.17.8.tar.gz&#8221;<\/p>\n\n\n\n<p>tar -zvxf nginx-1.17.8.tar.gz<\/p>\n\n\n\n<p>cd nginx-1.17.8\/<\/p>\n\n\n\n<p> .\/configure  &#8211;with-http_v2_module &#8211;with-http_gunzip_module &#8211;with-http_gzip_static_module  &#8211;with-http_ssl_module &#8211;add-module=RutaDelModuloClonadoConGit \u2013prefix=\/usr\/nginx-1.17.8<\/p>\n\n\n\n<p> make<\/p>\n\n\n\n<p> make install<\/p>\n<\/blockquote>\n\n\n\n<p><strong>Configurar nginx.conf<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>rtmp {<\/p>\n\n\n\n<p>     server {<\/p>\n\n\n\n<p>         listen 1935;<\/p>\n\n\n\n<p>         application dragontv {<\/p>\n\n\n\n<p>             live on;<\/p>\n\n\n\n<p>             record off;<\/p>\n\n\n\n<p>            push rtmp:\/\/www.lastdragon.net\/dragontv;<\/p>\n\n\n\n<p>         }<\/p>\n\n\n\n<p>     }<\/p>\n\n\n\n<p> }<\/p>\n<\/blockquote>\n\n\n\n<p><strong>Usar ffmpeg para transmitir archivos de videos al servicio rtmp en el mismo equipo<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>ffmpeg -re -y -i laeradelosofendidos.mp4 -vcodec libx264 -b:v 600k -r 25 -s 640&#215;360 -filter:v yadif -ab 64k -ac 1 -ar 44100 -f flv &#8220;rtmp:\/\/localhost\/dragontv&#8221;<\/p>\n<\/blockquote>\n\n\n\n<p><strong>Consumir los datos en streaming usando VLC<\/strong><\/p>\n\n\n\n<p>rtmp:\/\/www.lastdragon.net\/dragontv<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.lastdragon.net\/misarchivos\/rtmp.png\" alt=\"\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u00bf Para que ? Puedes tener un sistema de TV interno en lugares aislados como plataformas marinas, donde puedes usar la infraestructura de red para transportar video. Requerimientos El codec H264 para incluirlo en ffmpeg Nginx con el parche del modulo de rtmp para incluirlo en el Nginx Todo sera instalado desde sus fuentes, aunque&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2206,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-2205","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-consultoria-y-manuales"],"_links":{"self":[{"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=\/wp\/v2\/posts\/2205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2205"}],"version-history":[{"count":3,"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=\/wp\/v2\/posts\/2205\/revisions"}],"predecessor-version":[{"id":2575,"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=\/wp\/v2\/posts\/2205\/revisions\/2575"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=\/wp\/v2\/media\/2206"}],"wp:attachment":[{"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lastdragon.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}