[FFmpeg-user] Error: av_interleaved_write_frame(): Broken pipe

Aakash Gupta aakash.gupta96 at yahoo.in
Sun Feb 26 10:21:37 EET 2017




 Hello,

I have made a rails app that can stream live videos to facebook rtmp server and deployed it on Digital Ocean. I have used nginx as web server and using a linux OS. The major problem that I am encountering after viewing log files of FFMpeg processes is that after streaming for some time(that keeps on varying) FFmpeg process gives the error

av_interleaved_write_frame(): Broken pipe

This is the command that I am using:

$HOME/bin/ffmpeg -loop 1 -re -y -f image2 -i 'public/uploads/post/25/frame1.png' -acodec copy -bsf:a aac_adtstoasc -pix_fmt yuv420p -profile:v high -s 1280x720 -vb 400k -maxrate 400k -minrate 400k -bufsize 600k -deinterlace -vcodec libx264 -preset veryfast -g 30 -r 30 -t 14400 -strict -2 -f flv "rtmp_link" 2> "logfile"

Logs of this process:

ffmpeg version N-83442-gdac51d2 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
  libavutil      55. 46.100 / 55. 46.100
  libavcodec     57. 75.100 / 57. 75.100
  libavformat    57. 66.101 / 57. 66.101
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 73.100 /  6. 73.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, image2, from 'public/uploads/post/25/frame1.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 720x405, 25 fps, 25 tbr, 25 tbn, 25 tbc
[aac @ 0x2916fa0] Estimating duration from bitrate, this may be inaccurate
Input #1, aac, from 'public/silent.aac':
  Duration: 05:16:16.43, bitrate: 3 kb/s
    Stream #1:0: Audio: aac (LC), 44100 Hz, mono, fltp, 3 kb/s
[libx264 @ 0x291e8e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x291e8e0] profile High, level 3.1
[libx264 @ 0x291e8e0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 -"some link to be removed because of forum policy" - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=30 keyint_min=3 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=cbr mbtree=1 bitrate=400 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=400 vbv_bufsize=600 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'rtmp_link':
  Metadata:
    encoder         : Lavf57.66.101
    Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 1280x720, q=-1--1, 400 kb/s, 30 fps, 1k tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.75.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 400000/0/400000 buffer size: 600000 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, mono, fltp, 3 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[image2 @ 0x2914ae0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
frame=   12 fps=0.0 q=44.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   17 fps= 16 q=43.0 size=      22kB time=00:00:00.13 bitrate=1359.9kbits/s speed=0.13x    
frame=   28 fps= 18 q=42.0 size=      25kB time=00:00:00.56 bitrate= 367.1kbits/s speed=0.363x    
frame=   38 fps= 18 q=38.0 size=      41kB time=00:00:00.97 bitrate= 346.4kbits/s speed=0.465x    
frame=   48 fps= 18 q=38.0 size=      82kB time=00:00:01.37 bitrate= 490.0kbits/s speed=0.525x    
frame=   62 fps= 20 q=35.0 size=      96kB time=00:00:01.93 bitrate= 405.0kbits/s speed=0.617x    
frame=   71 fps= 19 q=30.0 size=     101kB time=00:00:02.27 bitrate= 363.9kbits/s speed=0.617x    
frame=   82 fps= 20 q=38.0 size=     150kB time=00:00:02.73 bitrate= 449.8kbits/s speed=0.651x    
frame=   97 fps= 21 q=28.0 size=     154kB time=00:00:03.33 bitrate= 379.5kbits/s speed=0.708x    
frame=  106 fps= 20 q=36.0 size=     209kB time=00:00:03.66 bitrate= 465.5kbits/s speed=0.702x    
frame=  121 fps= 21 q=36.0 size=     214kB time=00:00:04.27 bitrate= 409.6kbits/s speed=0.741x    
frame=  135 fps= 21 q=36.0 size=     269kB time=00:00:04.83 bitrate= 456.3kbits/s speed=0.768x    
frame=  144 fps= 21 q=36.0 size=     270kB time=00:00:05.20 bitrate= 425.4kbits/s speed=0.765x    
frame=  159 fps= 22 q=35.0 size=     273kB time=00:00:05.80 bitrate= 384.6kbits/s speed=0.794x    
frame=  170 fps= 22 q=37.0 size=     328kB time=00:00:06.23 bitrate= 430.8kbits/s speed=0.794x    
frame=  184 fps= 22 q=36.0 size=     330kB time=00:00:06.80 bitrate= 397.0kbits/s speed=0.814x    
frame=  199 fps= 22 q=35.0 size=     387kB time=00:00:07.40 bitrate= 427.6kbits/s speed=0.832x    
frame=  208 fps= 22 q=37.0 size=     387kB time=00:00:07.77 bitrate= 408.0kbits/s speed=0.827x    
frame=  222 fps= 22 q=36.0 size=     390kB time=00:00:08.33 bitrate= 382.9kbits/s speed=0.837x    
frame=  235 fps= 22 q=34.0 size=     444kB time=00:00:08.83 bitrate= 411.8kbits/s speed=0.842x    
frame=  249 fps= 23 q=35.0 size=     447kB time=00:00:09.40 bitrate= 389.5kbits/s speed=0.855x    
frame=  265 fps= 23 q=37.0 size=     506kB time=00:00:10.03 bitrate= 412.9kbits/s speed=0.87x    
frame=  279 fps= 23 q=35.0 size=     508kB time=00:00:10.61 bitrate= 392.0kbits/s speed=0.879x    
frame=  287 fps= 23 q=37.0 size=     562kB time=00:00:10.93 bitrate= 421.3kbits/s speed=0.868x    
frame=  302 fps= 23 q=36.0 size=     564kB time=00:00:11.53 bitrate= 400.7kbits/s speed=0.881x    
frame=  312 fps= 23 q=36.0 size=     566kB time=00:00:11.93 bitrate= 388.5kbits/s speed=0.876x    
frame=  324 fps= 23 q=36.0 size=     621kB time=00:00:12.40 bitrate= 410.1kbits/s speed=0.878x    
frame=  339 fps= 23 q=34.0 size=     624kB time=00:00:13.00 bitrate= 393.0kbits/s speed=0.886x    
frame=  348 fps= 23 q=36.0 size=     677kB time=00:00:13.37 bitrate= 415.0kbits/s speed=0.881x    
frame=  364 fps= 23 q=34.0 size=     682kB time=00:00:14.00 bitrate= 398.9kbits/s speed=0.892x    
frame=  375 fps= 23 q=36.0 size=     737kB time=00:00:14.44 bitrate= 418.3kbits/s speed=0.889x    
frame=  389 fps= 23 q=30.0 size=     739kB time=00:00:15.00 bitrate= 403.7kbits/s speed=0.894x    
frame=  402 fps= 23 q=36.0 size=     741kB time=00:00:15.53 bitrate= 390.7kbits/s speed=0.897x    
frame=  409 fps= 23 q=35.0 size=     796kB time=00:00:15.81 bitrate= 412.3kbits/s speed=0.886x    
frame=  422 fps= 23 q=36.0 size=     798kB time=00:00:16.33 bitrate= 400.0kbits/s speed=0.89x    
frame=  435 fps= 23 q=36.0 size=     854kB time=00:00:16.83 bitrate= 415.6kbits/s speed=0.892x    
frame=  447 fps= 23 q=35.0 size=     855kB time=00:00:17.33 bitrate= 404.1kbits/s speed=0.895x    
frame=  462 fps= 23 q=36.0 size=     857kB time=00:00:17.93 bitrate= 391.5kbits/s speed=0.901x    
frame=  473 fps= 23 q=37.0 size=     913kB time=00:00:18.36 bitrate= 407.2kbits/s speed= 0.9x    
frame=  488 fps= 23 q=35.0 size=     915kB time=00:00:18.97 bitrate= 395.1kbits/s speed=0.907x    
frame=  501 fps= 23 q=34.0 size=     971kB time=00:00:19.46 bitrate= 408.6kbits/s speed=0.908x    
frame=  512 fps= 23 q=36.0 size=     973kB time=00:00:19.93 bitrate= 399.7kbits/s speed=0.908x    
frame=  526 fps= 23 q=35.0 size=    1029kB time=00:00:20.46 bitrate= 411.9kbits/s speed=0.911x    
frame=  538 fps= 23 q=36.0 size=    1030kB time=00:00:20.96 bitrate= 402.5kbits/s speed=0.911x    
frame=  552 fps= 23 q=36.0 size=    1032kB time=00:00:21.53 bitrate= 392.7kbits/s speed=0.916x    
frame=  569 fps= 24 q=30.0 size=    1089kB time=00:00:22.20 bitrate= 401.8kbits/s speed=0.923x    
frame=  578 fps= 24 q=35.0 size=    1090kB time=00:00:22.57 bitrate= 395.7kbits/s speed=0.918x    
frame=  593 fps= 24 q=36.0 size=    1147kB time=00:00:23.17 bitrate= 405.5kbits/s speed=0.923x    
frame=  607 fps= 24 q=35.0 size=    1149kB time=00:00:23.73 bitrate= 396.5kbits/s speed=0.924x    
frame=  620 fps= 24 q=36.0 size=    1205kB time=00:00:24.24 bitrate= 407.4kbits/s speed=0.925x    
frame=  635 fps= 24 q=36.0 size=    1208kB time=00:00:24.84 bitrate= 398.2kbits/s speed=0.928x    
frame=  642 fps= 24 q=36.0 size=    1208kB time=00:00:25.13 bitrate= 393.8kbits/s speed=0.921x    
frame=  658 fps= 24 q=36.0 size=    1264kB time=00:00:25.77 bitrate= 401.8kbits/s speed=0.926x    
frame=  671 fps= 24 q=29.0 size=    1266kB time=00:00:26.26 bitrate= 394.9kbits/s speed=0.925x    
frame=  684 fps= 24 q=35.0 size=    1323kB time=00:00:26.80 bitrate= 404.4kbits/s speed=0.927x    
frame=  700 fps= 24 q=35.0 size=    1325kB time=00:00:27.43 bitrate= 395.7kbits/s speed=0.933x    
frame=  708 fps= 24 q=35.0 size=    1382kB time=00:00:27.77 bitrate= 407.5kbits/s speed=0.928x    
frame=  724 fps= 24 q=35.0 size=    1384kB time=00:00:28.40 bitrate= 399.1kbits/s speed=0.934x    
frame=  736 fps= 24 q=35.0 size=    1439kB time=00:00:28.86 bitrate= 408.3kbits/s speed=0.933x    
 

this goes on for some time and then this happens

frame=67234 fps= 25 q=35.0 size=  131284kB time=00:44:48.80 bitrate= 400.0kbits/s speed=0.992x    
frame=67242 fps= 25 q=36.0 size=  131286kB time=00:44:49.13 bitrate= 399.9kbits/s speed=0.992x    
frame=67255 fps= 25 q=36.0 size=  131341kB time=00:44:49.63 bitrate= 400.0kbits/s speed=0.992x    
frame=67268 fps= 25 q=35.0 size=  131343kB time=00:44:50.17 bitrate= 400.0kbits/s speed=0.992x    
frame=67276 fps= 25 q=35.0 size=  131399kB time=00:44:50.47 bitrate= 400.1kbits/s speed=0.992x    
frame=67290 fps= 25 q=36.0 size=  131401kB time=00:44:51.03 bitrate= 400.0kbits/s speed=0.992x    
frame=67304 fps= 25 q=33.0 size=  131457kB time=00:44:51.61 bitrate= 400.1kbits/s speed=0.992x    
frame=67313 fps= 25 q=37.0 size=  131458kB time=00:44:51.96 bitrate= 400.0kbits/s speed=0.992x    
frame=67326 fps= 25 q=35.0 size=  131460kB time=00:44:52.47 bitrate= 400.0kbits/s speed=0.992x    
frame=67338 fps= 25 q=35.0 size=  131514kB time=00:44:52.96 bitrate= 400.1kbits/s speed=0.992x    
frame=67346 fps= 25 q=35.0 size=  131515kB time=00:44:53.26 bitrate= 400.0kbits/s speed=0.992x    
frame=67362 fps= 25 q=36.0 size=  131519kB time=00:44:53.93 bitrate= 399.9kbits/s speed=0.992x    
frame=67377 fps= 25 q=35.0 size=  131575kB time=00:44:54.53 bitrate= 400.0kbits/s speed=0.992x    
frame=67387 fps= 25 q=33.0 size=  131576kB time=00:44:54.93 bitrate= 400.0kbits/s speed=0.992x    
frame=67401 fps= 25 q=34.0 size=  131632kB time=00:44:55.46 bitrate= 400.1kbits/s speed=0.992x    
frame=67416 fps= 25 q=35.0 size=  131635kB time=00:44:56.06 bitrate= 400.0kbits/s speed=0.992x    
frame=67425 fps= 25 q=36.0 size=  131690kB time=00:44:56.44 bitrate= 400.1kbits/s speed=0.992x    
frame=67440 fps= 25 q=36.0 size=  131692kB time=00:44:57.04 bitrate= 400.0kbits/s speed=0.992x    
frame=67454 fps= 25 q=33.0 size=  131748kB time=00:44:57.60 bitrate= 400.1kbits/s speed=0.992x    
frame=67464 fps= 25 q=35.0 size=  131749kB time=00:44:58.00 bitrate= 400.0kbits/s speed=0.992x    
frame=67478 fps= 25 q=35.0 size=  131751kB time=00:44:58.57 bitrate= 400.0kbits/s speed=0.992x    
frame=67489 fps= 25 q=35.0 size=  131807kB time=00:44:59.00 bitrate= 400.1kbits/s speed=0.992x    
av_interleaved_write_frame(): Broken pipe
[flv @ 0x291b140] Failed to update header with correct duration.
[flv @ 0x291b140] Failed to update header with correct filesize.
Error writing trailer of "rtmp_link": Broken pipeframe=67499 fps= 25 q=30.0 Lsize=  131809kB time=00:44:59.40 bitrate= 400.0kbits/s speed=0.992x    
video:128097kB audio:462kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.528061%
[libx264 @ 0x291e8e0] frame I:2250  Avg QP:29.45  size: 51998
[libx264 @ 0x291e8e0] frame P:17999 Avg QP:27.25  size:   691
[libx264 @ 0x291e8e0] frame B:47250 Avg QP:32.62  size:    37
[libx264 @ 0x291e8e0] consecutive B-frames:  6.7%  0.0%  0.0% 93.3%
[libx264 @ 0x291e8e0] mb I  I16..4: 15.0% 53.3% 31.7%
[libx264 @ 0x291e8e0] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  4.7%  0.4%  0.1%  0.0%  0.0%    skip:94.8%
[libx264 @ 0x291e8e0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct: 0.0%  skip:100.0%  L0:44.7% L1:54.1% BI: 1.2%
[libx264 @ 0x291e8e0] 8x8 transform intra:53.1% inter:28.1%
[libx264 @ 0x291e8e0] coded y,uvDC,uvAC intra: 83.3% 26.6% 22.9% inter: 0.4% 0.2% 0.0%
[libx264 @ 0x291e8e0] i16 v,h,dc,p: 27% 44% 25%  4%
[libx264 @ 0x291e8e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  3% 11% 13% 33%  1%  1%  2% 27%  9%
[libx264 @ 0x291e8e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 18% 11% 12%  7%  7%  5%  9%  6%
[libx264 @ 0x291e8e0] i8c dc,h,v,p: 77% 10% 10%  3%
[libx264 @ 0x291e8e0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x291e8e0] kb/s:388.66
Conversion failed!

In some cases, it runs perfectly without giving this error, but sometimes the above mentioned error disturbs the live streaming.

Please help me fix this issue :(

Thanks in advance 


   


More information about the ffmpeg-user mailing list