ut0mt8 / nginx-rtmp-module

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

Something is broken and after 2-4 seconds, ffmpeg launch "broken pipe" #1

Closed RafaelLinux closed 7 years ago

RafaelLinux commented 7 years ago

I gave a try to your fork, cause I'm very interested in ABR on DASH (dash_variant) that you implement in your fork. However, where Arut source and Sergey fork works fine, your fork fails, and that made me crazy cause I didn't think the problem was in your module. Please, take a look. Meanwhile, I continue using Sergey's fork.

Thank you

av_interleaved_write_frame(): Broken pipe
Error writing trailer

This is the complete output from ffmpeg

ffmpeg -re -f lavfi -i 'testsrc=size=1280x720:rate=24'  -f lavfi -i "sine=frequency=1000:sample_rate=44100,volume=0:enable='gt(t-trunc(t),0.25)'" -filter_complex "format=yuv420p, drawtext=fontcolor=white: fontsize=60: fontfile=/usr/share/fonts/truetype/LiberationMono-Bold.ttf: box=1:boxcolor=black@0.3: shadowcolor=black: shadowx=1: shadowy=1: x=(w-text_w-10):y=(h-text_h-5): timecode='00\:00\:00\:00': timecode_rate=24" -r 24 -c:v libx264 -profile:v baseline -level 3.0 -x264opts 'keyint=48:min-keyint=24:no-scenecut' -g 48 -keyint_min 24 -sc_threshold 0 -preset veryfast  -c:a aac -b:a 128k -ar 44100 -tune zerolatency -movflags +faststart -f flv "rtmp://ip_of_nginx_server/live/directo" 
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6 (SUSE Linux)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg --extra-cflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -g' --optflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -g' --disable-htmlpages --enable-pic --disable-stripping --enable-shared --disable-static --enable-gpl --disable-openssl --enable-avresample --enable-libcdio --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcelt --enable-libcdio --enable-libdc1394 --enable-libfreetype --enable-libgsm --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-netcdf --enable-vaapi --enable-vdpau --enable-libfdk_aac --enable-nonfree --enable-libmp3lame --enable-libtwolame --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, lavfi, from 'testsrc=size=1280x720:rate=24':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1280x720 [SAR 1:1 DAR 16:9], 24 tbr, 24 tbn, 24 tbc
Input #1, lavfi, from 'sine=frequency=1000:sample_rate=44100,volume=0:enable='gt(t-trunc(t),0.25)'':
  Duration: N/A, start: 0.000000, bitrate: 1411 kb/s
    Stream #1:0: Audio: pcm_f32le, 44100 Hz, mono, flt, 1411 kb/s
[libx264 @ 0x847320] using SAR=1/1
[libx264 @ 0x847320] frame MB size (80x45) > level limit (1620)
[libx264 @ 0x847320] MB rate (86400) > level limit (40500)                                                                  
[libx264 @ 0x847320] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 0x847320] profile Constrained Baseline, level 3.0
[libx264 @ 0x847320] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=2 lookahead_threads=2 sliced_threads=1 slices=2 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=48 keyint_min=24 scenecut=0 intra_refresh=0 rc=crf mbtree=0 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://10.162.0.30/live/directo':
  Metadata:
    encoder         : Lavf57.56.101
    Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 1k tbn, 24 tbc
    Metadata:
      encoder         : Lavc57.64.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, mono, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.64.101 aac
Stream mapping:
  Stream #0:0 (rawvideo) -> format (graph 0)
  drawtext (graph 0) -> Stream #0:0 (libx264)
  Stream #1:0 -> #0:1 (pcm_f32le (native) -> aac (native))
Press [q] to stop, [?] for help
av_interleaved_write_frame(): Broken pipeB time=00:00:03.58 bitrate= 453.1kbits/s speed=   1x
Error writing trailer of rtmp://10.162.0.30/live/directo: Broken pipeframe=   98 fps= 24 q=21.0 Lsize=     237kB time=00:00:04.06 bitrate= 477.3kbits/s speed=   1x
video:213kB audio:19kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.292459%
[libx264 @ 0x847320] frame I:3     Avg QP: 5.33  size: 18520
[libx264 @ 0x847320] frame P:95    Avg QP: 8.33  size:  1701
[libx264 @ 0x847320] mb I  I16..4: 91.0%  0.0%  9.0%
[libx264 @ 0x847320] mb P  I16..4:  7.5%  0.0%  0.1%  P16..4:  3.4%  1.2%  0.1%  0.0%  0.0%    skip:87.7%
[libx264 @ 0x847320] coded y,uvDC,uvAC intra: 2.8% 21.0% 13.7% inter: 0.3% 1.8% 0.2%
[libx264 @ 0x847320] i16 v,h,dc,p: 90%  6%  1%  3%
[libx264 @ 0x847320] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 48% 26% 18%  2%  1%  2%  1%  2%  1%
[libx264 @ 0x847320] i8c dc,h,v,p: 23%  7% 59% 11%
[libx264 @ 0x847320] kb/s:425.52
[aac @ 0x84abe0] Qavg: 55608.855
Conversion failed!
ut0mt8 commented 7 years ago

Thanks for trying my fork. Can you post the complete "nginx.conf" used ? Did you notice any fatal error in nginx log ? segfault ? Is the exact same config work with sergey fork ?

Btw broken pipe in the ingress ffmpeg surely mean that ngx close the connection or misbehave. You can also use a separate script (in a screen for example) in place of using the exec directive of nginx for transcoding. It is easier to debug, and see what part is non working.

RafaelLinux commented 7 years ago

I'm sorry. I didn't notice any reply on my inbox. I can't say nothing about your questions just now, cause I decided to choose HLS format for two reasons:

Moreover, I wanted to use DASH to get Opera to play the video, but Opera needs WebM (not MP4) to run and unfortunately nginx doesn't work with WebM.

Can your fork make nginx work with WebM over DASH?

ut0mt8 commented 7 years ago

I understand. hls is a more versatile format at time. Nginx rtmp understand only h264 /mp4. Multi browser support is a nighmare... we end by not support safari and opera...