0

I'm using ffmpeg to stream using the SRT protocol, with for example this command:

ffmpeg -re -f lavfi -i testsrc \
  -c:v libx264 -g 25 -preset veryfast -tune zerolatency -r 25 \
  -f mpegts "srt://0.0.0.0:1920?mode=listener"

This is the initial output:

ffmpeg version 4.4-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, lavfi, from 'testsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc

When I start playing it with VLC I get this additional output from ffmpeg, and it plays fine:

Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x76eb2c0] using SAR=1/1
[libx264 @ 0x76eb2c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x76eb2c0] profile High 4:4:4 Predictive, level 1.3, 4:4:4, 8-bit
Output #0, mpegts, to 'srt://0.0.0.0:1920?mode=listener':
  Metadata:
    encoder         : Lavf58.76.100
  Stream #0:0: Video: h264, yuv444p(tv, progressive), 320x240 [SAR 1:1 DAR 4:3], q=2-31, 25 fps, 90k tbn
    Metadata:
      encoder         : Lavc58.134.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=  531 fps= 25 q=18.0 size=     485kB time=00:00:21.20 bitrate= 187.2kbits/s speed=   1x       

But as soon as I stop playback in VLC, ffmpeg aborts and exits:

av_interleaved_write_frame(): Input/output error
Error writing trailer of srt://0.0.0.0:1920?mode=listener: Input/output error
video:1362kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 42.061180%
[libx264 @ 0x76eb2c0] frame I:85    Avg QP: 8.75  size:  4147
[libx264 @ 0x76eb2c0] frame P:2032  Avg QP: 7.93  size:   513
[libx264 @ 0x76eb2c0] mb I  I16..4: 56.9%  7.6% 35.6%
[libx264 @ 0x76eb2c0] mb P  I16..4:  2.9%  3.3%  0.3%  P16..4:  8.0%  4.0%  1.5%  0.0%  0.0%    skip:80.0%
[libx264 @ 0x76eb2c0] 8x8 transform intra:33.5% inter:5.3%
[libx264 @ 0x76eb2c0] coded y,u,v intra: 22.4% 22.5% 19.0% inter: 2.5% 2.5% 2.3%
[libx264 @ 0x76eb2c0] i16 v,h,dc,p: 62% 14%  7% 17%
[libx264 @ 0x76eb2c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 98%  0%  1%  0%  0%  0%  0%  0%  0%
[libx264 @ 0x76eb2c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 43% 32% 20%  1%  1%  1%  0%  1%  0%
[libx264 @ 0x76eb2c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x76eb2c0] kb/s:131.75
Conversion failed!

Is it possible to tell ffmpeg to keep streaming so that clients can reconnect directly, without having to restart the sending stream first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.