Answer the question
In order to leave comments, you need to log in
How to make external broadcast of RTMP stream via ffmpeg?
I need to make an external broadcast of an RTMP stream from a file so that it can be played on the site. It turns out to do it locally, i.e. I start the broadcast and I can connect to it locally, but I can’t connect from outside, what am I doing wrong?
nginx.conf config
#user nobody;
worker_processes auto;
worker_rlimit_nofile 65536;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
# rtmp stat
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/build/nginx-rtmp-module;
}
# rtmp control
location /control {
rtmp_control all;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp {
server {
listen 1935;
ping 30s;
notify_method get;
application live {
live on;
allow play all;
allow publish 127.0.0.1;
}
}
}
ffmpeg -re -i /var/videos/test.mp4 -c copy -f flv rtmp://localhost/live/stream
[[email protected] ~]# ffmpeg -re -i /var/videos/test.mp4 -c copy -f flv rtmp://localhost/live/stream
ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 13 2014 13:00:18 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/videos/test.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2017-08-29 08:33:09
Duration: 00:04:39.85, start: 0.000000, bitrate: 1123 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 994 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
creation_time : 2017-08-29 08:33:09
handler_name : ISO Media file produced by Google Inc. Created on: 08/29/2017.
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
creation_time : 2017-08-29 08:33:09
handler_name : ISO Media file produced by Google Inc. Created on: 08/29/2017.
Output #0, flv, to 'rtmp://localhost/live/stream':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf55.33.100
Stream #0:0(und): Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 994 kb/s, 25 fps, 1k tbn, 90k tbc (default)
Metadata:
creation_time : 2017-08-29 08:33:09
handler_name : ISO Media file produced by Google Inc. Created on: 08/29/2017.
Stream #0:1(und): Audio: aac ([10][0][0][0] / 0x000A), 44100 Hz, stereo, 125 kb/s (default)
Metadata:
creation_time : 2017-08-29 08:33:09
handler_name : ISO Media file produced by Google Inc. Created on: 08/29/2017.
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 15 fps=0.0 q=-1.0 size= 543kB time=00:00:00.52 bitrate=8560.7kbits/
frame= 28 fps= 28 q=-1.0 size= 1061kB time=00:00:01.04 bitrate=8355.8kbits/
frame= 41 fps= 27 q=-1.0 size= 1419kB time=00:00:01.56 bitrate=7452.9kbits/
frame= 53 fps= 26 q=-1.0 size= 1430kB time=00:00:02.04 bitrate=5744.0kbits/
frame= 66 fps= 26 q=-1.0 size= 1441kB time=00:00:02.56 bitrate=4610.7kbits/
frame= 79 fps= 26 q=-1.0 size= 1451kB time=00:00:03.08 bitrate=3860.5kbits/
frame= 91 fps= 26 q=-1.0 size= 1463kB time=00:00:03.56 bitrate=3365.5kbits/
frame= 104 fps= 26 q=-1.0 size= 1473kB time=00:00:04.08 bitrate=2958.5kbits/
frame= 117 fps= 26 q=-1.0 size= 1487kB time=00:00:04.60 bitrate=2647.3kbits/
ffplay rtmp://5.23.55.156/live/stream
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question