arut / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
13.51k stars 3.52k forks source link

Stream freezes after a minute. #1611

Open Foxar opened 3 years ago

Foxar commented 3 years ago

Hello. While attempting to use nginx-rtmp to create a video/audio stream, I've discovered that both of my means of sending the stream to nginx server freeze after some time (anywhere from 30 to 90 seconds). I attempted to use OBS with custom settings for nginx-rtmp at localhost, as well as FFMPeg. In case of OBS after around 40 seconds or so the square in the corner goes red indicating no more data is being sent. In case of FFMPeg it just simply freezes:

$ sudo ffmpeg -loglevel verbose -re -i long.mp4 -vcodec libx264 -vprofile baseline -acodec aac -strict -2 -f flv rtmp://localhost/show/stream ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-10ubuntu2) configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 Routing option strict to both codec and muxer layer [h264 @ 0x7fffd5544180] Reinit context to 864x480, pix_fmt: yuv420p Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'long.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.19.102 Duration: 00:01:56.91, start: 0.000000, bitrate: 500 kb/s Stream #0:0(und): Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, left), 854x480 (864x480) [SAR 1:1 DAR 427:240], 364 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default) Metadata: handler_name : ISO Media file produced by Google Inc. Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : ISO Media file produced by Google Inc. [tcp @ 0x7fffd5582980] Starting connection attempt to 127.0.0.1 port 1935 [tcp @ 0x7fffd5582980] Successfully connected to 127.0.0.1 port 1935 Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Press [q] to stop, [?] for help [h264 @ 0x7fffd5573f80] Reinit context to 864x480, pix_fmt: yuv420p [graph_1_in_0_1 @ 0x7fffd58a1bc0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3 [graph 0 input from stream 0:0 @ 0x7fffd55c31c0] w:854 h:480 pixfmt:yuv420p tb:1/30000 fr:30000/1001 sar:1/1 sws_param:flags=2 [libx264 @ 0x7fffd55b0d80] using SAR=1/1 [libx264 @ 0x7fffd55b0d80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 [libx264 @ 0x7fffd55b0d80] profile Constrained Baseline, level 3.1 [libx264 @ 0x7fffd55b0d80] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=15 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, flv, to 'rtmp://localhost/show/stream': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Stream #0:0(und): Video: h264 (libx264), 1 reference frame ([7][0][0][0] / 0x0007), yuv420p(left), 854x480 [SAR 1:1 DAR 427:240], q=-1--1, 29.97 fps, 1k tbn, 29.97 tbc (default) Metadata: handler_name : ISO Media file produced by Google Inc. encoder : Lavc58.54.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 Stream #0:1(eng): Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp, delay 1024, 128 kb/s (default) Metadata: handler_name : ISO Media file produced by Google Inc. encoder : Lavc58.54.100 aac ^Came= 1200 fps= 30 q=29.0 size= 3312kB time=00:00:40.37 bitrate= 672.0kbits/s speed=0.999x

In this case, it held at 40 seconds in while analyzing the video. I'm including my error.log (with debug logging included), as well as the nginx configuration I'm using (as .txt files because github doesn't like other kinds of files.). (Also notice I've disabled some portions of the config, by commenting them out, that I originally wanted in the project I'm making, but I'm encountering the problem with and without them.) error.log.txt nginx.conf.txt Please help me out, what am I doing incorrectly? Is it a bug within nginx-rtmp? Thank you ahead of time.

Foxar commented 3 years ago

Okay, I've seem to have identified the issue, being too high quality of the input stream. While using OBS setting extremely low bitrates have resulted in a stable streaming, so if anyone runs into same issue, do that.

Perhaps some kind of error message would be nice though from nginx to signify that it is being overwhelmed, or otherwise why the HLS fragment creation ceased.