Error - not working
prof-rt opened this issue · 12 comments
Unfortunately I can't get it to work:
Please note that i compiled this as a dynamic module, using the stock nginx deb dist 1.12.2, I hope this should not make major difference.
ffmpeg ouput:
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
av_interleaved_write_frame(): Connection reset by peer
Error writing trailer of rtmp://localhost/myapp/mystream: Connection reset by peerframe= 4 fps=0.0 q=-1.0 Lsize= 7kB time=00:00:00.12 bitrate= 501.1kbits/s speed=1.48x
video:7kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 7.290487%
Conversion failed!
The nginx error log:
2017/11/18 10:20:30 [notice] 11404#11404: using the "epoll" event method
2017/11/18 10:20:30 [notice] 11404#11404: nginx/1.12.2
2017/11/18 10:20:30 [notice] 11404#11404: built by gcc 6.3.0 20170516 (Debian 6.3.0-18)
2017/11/18 10:20:30 [notice] 11404#11404: OS: Linux 4.9.0-4-686-pae
2017/11/18 10:20:30 [notice] 11404#11404: getrlimit(RLIMIT_NOFILE): 1024:4096
2017/11/18 10:20:30 [notice] 11405#11405: start worker processes
2017/11/18 10:20:30 [notice] 11405#11405: start worker process 11408
2017/11/18 10:20:46 [info] 11408#11408: *1 client connected '127.0.0.1'
2017/11/18 10:20:46 [info] 11408#11408: *1 connect: app='myapp' args='' flashver='FMLE/3.0 (compatible; Lavf57.56' swf_url='' tc_url='rtmp://localhost:1935/myapp' page_url='' acodecs=0 vcodecs=0 object_encoding=0, client: 127.0.0.1, server: 0.0.0.0:1935
2017/11/18 10:20:46 [info] 11408#11408: *1 createStream, client: 127.0.0.1, server: 0.0.0.0:1935
2017/11/18 10:20:46 [info] 11408#11408: *1 publish: name='mystream' args='' type=live silent=0, client: 127.0.0.1, server: 0.0.0.0:1935
*** stack smashing detected ***: nginx: worker process terminated
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x6737a)[0xb724f37a]
/lib/i386-linux-gnu/libc.so.6(__fortify_fail+0x37)[0xb72dff37]
/lib/i386-linux-gnu/libc.so.6(+0xf7ef8)[0xb72dfef8]
/usr/lib/nginx/modules/ngx_rtmp_module.so(_fini+0x0)[0xb6abcbc4]
/usr/lib/nginx/modules/ngx_rtmp_module.so(+0x3e545)[0xb6abc545]
/usr/lib/nginx/modules/ngx_rtmp_module.so(+0x12da9)[0xb6a90da9]
/usr/lib/nginx/modules/ngx_rtmp_module.so(ngx_rtmp_amf_message_handler+0x15f)[0xb6a8d11f]
/usr/lib/nginx/modules/ngx_rtmp_module.so(ngx_rtmp_receive_message+0x58)[0xb6a896b8]
/usr/lib/nginx/modules/ngx_rtmp_module.so(+0xbc84)[0xb6a89c84]
nginx: worker process(+0x3e63b)[0x52763b]
nginx: worker process(ngx_process_events_and_timers+0x71)[0x51e211]
nginx: worker process(+0x3c4f4)[0x5254f4]
nginx: worker process(ngx_spawn_process+0x174)[0x523e64]
nginx: worker process(+0x3c711)[0x525711]
nginx: worker process(ngx_master_process_cycle+0x1bd)[0x52628d]
nginx: worker process(main+0xbfb)[0x4fe6ab]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf6)[0xb7200276]
nginx: worker process(+0x15834)[0x4fe834]
======= Memory map: ========
004e9000-00607000 r-xp 00000000 08:01 401607 /usr/sbin/nginx
00607000-00609000 r--p 0011d000 08:01 401607 /usr/sbin/nginx
00609000-0061d000 rw-p 0011f000 08:01 401607 /usr/sbin/nginx
0061d000-00637000 rw-p 00000000 00:00 0
019dc000-01a1e000 rw-p 00000000 00:00 0 [heap]
01a1e000-01a52000 rw-p 00000000 00:00 0 [heap]
b6a0c000-b6a28000 r-xp 00000000 08:01 327685 /lib/i386-linux-gnu/libgcc_s.so.1
b6a28000-b6a29000 r--p 0001b000 08:01 327685 /lib/i386-linux-gnu/libgcc_s.so.1
b6a29000-b6a2a000 rw-p 0001c000 08:01 327685 /lib/i386-linux-gnu/libgcc_s.so.1
b6a3a000-b6a45000 r-xp 00000000 08:01 327931 /lib/i386-linux-gnu/libnss_files-2.24.so
b6a45000-b6a46000 r--p 0000a000 08:01 327931 /lib/i386-linux-gnu/libnss_files-2.24.so
b6a46000-b6a47000 rw-p 0000b000 08:01 327931 /lib/i386-linux-gnu/libnss_files-2.24.so
b6a47000-b6a4d000 rw-p 00000000 00:00 0
b6a4d000-b6a58000 r-xp 00000000 08:01 327939 /lib/i386-linux-gnu/libnss_nis-2.24.so
b6a58000-b6a59000 r--p 0000a000 08:01 327939 /lib/i386-linux-gnu/libnss_nis-2.24.so
b6a59000-b6a5a000 rw-p 0000b000 08:01 327939 /lib/i386-linux-gnu/libnss_nis-2.24.so
b6a5a000-b6a70000 r-xp 00000000 08:01 327916 /lib/i386-linux-gnu/libnsl-2.24.so
b6a70000-b6a71000 r--p 00016000 08:01 327916 /lib/i386-linux-gnu/libnsl-2.24.so
b6a71000-b6a72000 rw-p 00017000 08:01 327916 /lib/i386-linux-gnu/libnsl-2.24.so
b6a72000-b6a74000 rw-p 00000000 00:00 0
b6a74000-b6a7c000 r-xp 00000000 08:01 327924 /lib/i386-linux-gnu/libnss_compat-2.24.so
b6a7c000-b6a7d000 r--p 00007000 08:01 327924 /lib/i386-linux-gnu/libnss_compat-2.24.so
b6a7d000-b6a7e000 rw-p 00008000 08:01 327924 /lib/i386-linux-gnu/libnss_compat-2.24.so
b6a7e000-b6ad5000 r-xp 00000000 08:01 60428 /usr/lib/nginx/modules/ngx_rtmp_module.so
b6ad5000-b6ad6000 r--p 00056000 08:01 60428 /usr/lib/nginx/modules/ngx_rtmp_module.so
b6ad6000-b6adb000 rw-p 00057000 08:01 60428 /usr/lib/nginx/modules/ngx_rtmp_module.so
b6adb000-b71e8000 rw-p 00000000 00:00 0
b71e8000-b7399000 r-xp 00000000 08:01 327858 /lib/i386-linux-gnu/libc-2.24.so
b7399000-b739a000 ---p 001b1000 08:01 327858 /lib/i386-linux-gnu/libc-2.24.so
b739a000-b739c000 r--p 001b1000 08:01 327858 /lib/i386-linux-gnu/libc-2.24.so
b739c000-b739d000 rw-p 001b3000 08:01 327858 /lib/i386-linux-gnu/libc-2.24.so
b739d000-b73a0000 rw-p 00000000 00:00 0
b73a0000-b73b9000 r-xp 00000000 08:01 328191 /lib/i386-linux-gnu/libz.so.1.2.8
b73b9000-b73ba000 r--p 00018000 08:01 328191 /lib/i386-linux-gnu/libz.so.1.2.8
b73ba000-b73bb000 rw-p 00019000 08:01 328191 /lib/i386-linux-gnu/libz.so.1.2.8
b73bb000-b7606000 r-xp 00000000 08:01 459041 /usr/lib/i386-linux-gnu/libcrypto.so.1.1
b7606000-b7607000 ---p 0024b000 08:01 459041 /usr/lib/i386-linux-gnu/libcrypto.so.1.1
b7607000-b7618000 r--p 0024b000 08:01 459041 /usr/lib/i386-linux-gnu/libcrypto.so.1.1
b7618000-b761f000 rw-p 0025c000 08:01 459041 /usr/lib/i386-linux-gnu/libcrypto.so.1.1
b761f000-b7622000 rw-p 00000000 00:00 0
b7622000-b7689000 r-xp 00000000 08:01 459042 /usr/lib/i386-linux-gnu/libssl.so.1.1
b7689000-b768c000 r--p 00066000 08:01 459042 /usr/lib/i386-linux-gnu/libssl.so.1.1
b768c000-b7690000 rw-p 00069000 08:01 459042 /usr/lib/i386-linux-gnu/libssl.so.1.1
b7690000-b7707000 r-xp 00000000 08:01 327846 /lib/i386-linux-gnu/libpcre.so.3.13.3
b7707000-b7708000 r--p 00076000 08:01 327846 /lib/i386-linux-gnu/libpcre.so.3.13.3
b7708000-b7709000 rw-p 00077000 08:01 327846 /lib/i386-linux-gnu/libpcre.so.3.13.3
b7709000-b7712000 r-xp 00000000 08:01 327868 /lib/i386-linux-gnu/libcrypt-2.24.so
b7712000-b7713000 r--p 00008000 08:01 327868 /lib/i386-linux-gnu/libcrypt-2.24.so
b7713000-b7714000 rw-p 00009000 08:01 327868 /lib/i386-linux-gnu/libcrypt-2.24.so
b7714000-b773b000 rw-p 00000000 00:00 0
b773b000-b7754000 r-xp 00000000 08:01 327961 /lib/i386-linux-gnu/libpthread-2.24.so
b7754000-b7755000 r--p 00018000 08:01 327961 /lib/i386-linux-gnu/libpthread-2.24.so
b7755000-b7756000 rw-p 00019000 08:01 327961 /lib/i386-linux-gnu/libpthread-2.24.so
b7756000-b7758000 rw-p 00000000 00:00 0
b7758000-b775b000 r-xp 00000000 08:01 327877 /lib/i386-linux-gnu/libdl-2.24.so
b775b000-b775c000 r--p 00002000 08:01 327877 /lib/i386-linux-gnu/libdl-2.24.so
b775c000-b775d000 rw-p 00003000 08:01 327877 /lib/i386-linux-gnu/libdl-2.24.so
b776a000-b776b000 rw-p 00000000 00:00 0
b776b000-b776c000 rw-s 00000000 00:0d 228956 /[aio] (deleted)
b776c000-b776d000 rw-s 00000000 00:05 228952 /dev/zero (deleted)
b776d000-b776f000 rw-p 00000000 00:00 0
b776f000-b7771000 r--p 00000000 00:00 0 [vvar]
b7771000-b7773000 r-xp 00000000 00:00 0 [vdso]
b7773000-b7796000 r-xp 00000000 08:01 327758 /lib/i386-linux-gnu/ld-2.24.so
b7796000-b7797000 r--p 00022000 08:01 327758 /lib/i386-linux-gnu/ld-2.24.so
b7797000-b7798000 rw-p 00023000 08:01 327758 /lib/i386-linux-gnu/ld-2.24.so
bf90c000-bf92d000 rw-p 00000000 00:00 0 [stack]
2017/11/18 10:20:46 [notice] 11405#11405: signal 17 (SIGCHLD) received
2017/11/18 10:20:46 [alert] 11405#11405: worker process 11408 exited on signal 6
I used nginx-1.12.2 stable version from official site, but can't reproduce the error. Could you please paste your conf file?
I initially used the example you provided, then tried to simply based on a working example that I had from the original ngx_rtmp_module.
load_module /usr/lib/nginx/modules/ngx_rtmp_module.so;
error_log /var/log/nginx/error.log debug;
#worker_processes 4;
##worker_cpu_affinity 0001 0010 0100 1000;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
server {
listen 8080;
location / {
root /var/www/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /live {
flv_live on; #open flv live streaming (subscribe)
chunked on; #open 'Transfer-Encoding: chunked' response
}
location /stat {
#configuration of push & pull status
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/src/nginx-rtmp-module/stat.xsl; #specify in where stat.xsl located
}
}
}
#rtmp_auto_push on;
#rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;
rtmp {
#out_queue 4096;
#out_cork 8;
#max_streams 64;
ping 30s;
notify_method get;
server {
listen 1935;
server_name localhost;
application myapp {
live on;
#gop_cache on; #open GOP cache for low latency
}
}
#server {
#listen 1945;
#application myapp {
#live on;
#gop_cache on; #open GOP cache for low latency
#}
#}
#server {
#listen 1985;
#application myapp {
#proxy_pass rtmp://balance; #open reverse proxy
#}
#}
#upstream balance {
#open load balance
#server localhost:1935;
#server localhost:1945;
#}
I've tried my best to reproduce the error, but unfortunately, I haven’t made any progress until now. The differences of environment between you and me now are only Linux kernel and gcc versions.
From your error.log, I found a clue on stackoverflow: https://stackoverflow.com/questions/1345670/stack-smashing-detected, that may be the reason.
At last, I advise you to compile nginx with an option '--with-debug', otherwise setting 'debug' for 'error_log' directive makes no sense. Note that if you do so, nginx will log huge information in error.log, but that may be of great help to find out the reason of the error.
ok, the above problem is due to one of my configure settings:
root@lamp:/usr/src/nginx-1.12.2/objs# nginx -V
nginx version: nginx/1.12.2
built by gcc 6.3.0 20170516 (Debian 6.3.0-18)
built with OpenSSL 1.1.0f 25 May 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --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_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.12.2/debian/debuild-base/nginx-1.12.2=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
I went back to basics:
nginx src: 1.12.2 from deb src from nginx.org
your vanilla nginx-http-flv-module
I compiled with this option:
:/usr/src/nginx-1.12.2/objs# ./nginx -V
nginx version: nginx/1.12.2
built by gcc 6.3.0 20170516 (Debian 6.3.0-18)
built with OpenSSL 1.1.0f 25 May 2017
TLS SNI support enabled
configure arguments: --modules-path=/usr/lib/nginx/modules --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --add-module=/usr/src/nginx-http-flv-module
and this compiled, and executed well.
however!
I can't get the video to stream!!
ffmpeg -re -i test2.mp4 -vcodec copy -acodec copy -f flv rtmp://localhost/myapp/mystream -- works
however on client:
mpv windows>mpv -cache=no -v "http://192.168.1.19:8080/live?port=1935&app=myapp&stream=mystream"
[cplayer] mpv 0.27.0 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
[cplayer] built on Wed Sep 13 04:17:50 CEST 2017
[cplayer] ffmpeg library versions:
[cplayer] libavutil 55.74.100
[cplayer] libavcodec 57.105.100
[cplayer] libavformat 57.82.100
[cplayer] libswscale 4.7.103
[cplayer] libavfilter 6.105.100
[cplayer] libswresample 2.8.100
[cplayer] ffmpeg version: N-87286-g6ce4a635ed
[cplayer] Run command: hook-ack, flags=0, args=[on_load]
[ffmpeg] Opening http://192.168.1.19:8080/live?port=1935&app=myapp&stream=mystream
[ffmpeg] Could not set AVOption tls_verify='0'
[ffmpeg] Mime-type: 'video/x-flv'
[ffmpeg] Stream opened successfully.
[demux] Trying demuxers for level=normal.
[lavf] Found 'live_flv' at score=100 size=2048.
[ffmpeg/demuxer] live_flv: Packet mismatch -420612376 668991 669399
[ffmpeg] Cannot seek backward in linear streams!
my nginx.conf:
error_log /var/log/nginx/error.log debug;
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
server {
listen 8080;
location / {
root /var/www/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /live {
flv_live on; #open flv live streaming (subscribe)
chunked on; #open 'Transfer-Encoding: chunked' response
}
location /stat {
#configuration of push & pull status
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/src/nginx-rtmp-module/stat.xsl; #specify in where stat.xsl located
}
}
}
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;
rtmp {
out_queue 4096;
out_cork 8;
max_streams 64;
#ping 30s;
#notify_method get;
server {
listen 1935;
server_name localhost;
application myapp {
live on;
gop_cache on; #open GOP cache for low latency
}
}
server {
listen 1945;
application myapp {
live on;
gop_cache on; #open GOP cache for low latency
}
}
}
OK, I reproduced the error, turn off the 'gop_cache' directive or comment it out to see if it works, there is a bug. Turning off it will take you a longer time to see the first picture of the video.
Thanks your patient test!
Unfortunately still doesn't work
[cplayer] Playing: http://192.168.1.19:8080/live?port=1935&app=myapp&stream=mystream
[cplayer] Run command: hook-ack, flags=0, args=[on_load]
[ffmpeg] Opening http://192.168.1.19:8080/live?port=1935&app=myapp&stream=mystream
[ffmpeg] Could not set AVOption tls_verify='0'
[ffmpeg] Mime-type: 'video/x-flv'
[ffmpeg] Stream opened successfully.
[cache] Cache size set to 150000 KiB (75000 KiB backbuffer)
[demux] Trying demuxers for level=normal.
[lavf] Found 'live_flv' at score=100 size=2048.
[ffmpeg/demuxer] live_flv: Packet mismatch 1784240686 668992 669400
I had some success with commenting out chunked on; this allowed me to view video in vlc and mpv.
However i could not get flv.js or videojs-flvjs to work in a browser.
So it is certain that mpv doesn't support HTTP chunked transmission, vlc supports both 'Expires: -1' and 'Transfer-Encoding: chunked' HTTP headers, so does OBS.
