[FFmpeg-user] timeout ffmpeg, Ctrl+C -> Immediate exit requested

Andriy Utkin andrey_utkin at fastmail.com
Sun Jul 23 01:23:46 EEST 2023


Visual demo of the issue:
timeout ffmpeg - bad: https://asciinema.org/a/ct5E8GGNhqMaV8nCzY27r4VeY
just ffmpeg - good: https://asciinema.org/a/CT1DPwUWanyRMl3gWyGKl638n

I tend to run ffmpeg with "timeout" when I am recording something which has a predictable duration limit.
That works well, but surprise comes when I attend to that process and hit Ctrl+C earlier.
It terminates, but with "Immediate exit requested" message, which implies not flushing buffered frames in the encoder and the container is also not finalized. This happens *almost* every time.
This doesn't happen when "timeout" utility is not used. Ctrl+C just terminates the process gracefully.
This is not big deal as I am saving to Matroska - I don't seem to lose much stream data.
But something is not correct here.
I know there's --foreground option, but with it the situation stays the same.
I am almost sure the problem is on "timeout" side, and I intend to investigate this further myself.
But if anybody has noticed this before, and have some findings to share, that would be great.


 $ timeout 10 ffmpeg -f lavfi -i testsrc -c libx264 -f matroska -y /dev/null
ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libjxl --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-libplacebo --enable-librsvg --enable-librav1e --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libshaderc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libmfx --enable-runtime-cpudetect
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.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
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x55f4e4a04d00] using SAR=1/1
[libx264 @ 0x55f4e4a04d00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55f4e4a04d00] profile High 4:4:4 Predictive, level 1.3, 4:4:4, 8-bit
[libx264 @ 0x55f4e4a04d00] 264 - core 164 r3095 baee400 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=7 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=2 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, matroska, to '/dev/null':
  Metadata:
    encoder         : Lavf59.27.100
  Stream #0:0: Video: h264 (H264 / 0x34363248), yuv444p(tv, progressive), 320x240 [SAR 1:1 DAR 4:3], q=2-31, 25 fps, 1k tbn
    Metadata:
      encoder         : Lavc59.37.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Error writing trailer of /dev/null: Immediate exit requestedbitrate=  33.2kbits/s speed=56.7x
frame= 1326 fps=0.0 q=-1.0 Lsize=     243kB time=00:00:52.92 bitrate=  37.6kbits/s speed=55.2x
video:234kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.849787%
Error closing file /dev/null: Immediate exit requested
[libx264 @ 0x55f4e4a04d00] frame I:6     Avg QP:17.02  size:  3344
[libx264 @ 0x55f4e4a04d00] frame P:358   Avg QP:14.03  size:   472
[libx264 @ 0x55f4e4a04d00] frame B:962   Avg QP:14.29  size:    52
[libx264 @ 0x55f4e4a04d00] consecutive B-frames:  1.1%  0.0% 19.9% 79.0%
[libx264 @ 0x55f4e4a04d00] mb I  I16..4: 30.8% 39.3% 29.8%
[libx264 @ 0x55f4e4a04d00] mb P  I16..4:  1.9%  1.5%  0.8%  P16..4:  7.3%  3.8%  2.6%  0.0%  0.0%    skip:82.1%
[libx264 @ 0x55f4e4a04d00] mb B  I16..4:  0.2%  0.1%  0.0%  B16..8:  4.3%  0.1%  0.0%  direct: 0.1%  skip:95.3%  L0:53.2% L1:42.4% BI: 4.4%
[libx264 @ 0x55f4e4a04d00] 8x8 transform intra:37.8% inter:37.6%
[libx264 @ 0x55f4e4a04d00] coded y,u,v intra: 10.1% 10.7% 8.7% inter: 0.7% 0.8% 0.7%
[libx264 @ 0x55f4e4a04d00] i16 v,h,dc,p: 51% 31%  1% 16%
[libx264 @ 0x55f4e4a04d00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 66%  5% 29%  0%  0%  0%  0%  0%  0%
[libx264 @ 0x55f4e4a04d00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 53% 12%  1%  1%  1%  0%  1%  0%
[libx264 @ 0x55f4e4a04d00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x55f4e4a04d00] ref P L0: 68.4%  7.0% 21.2%  3.3%
[libx264 @ 0x55f4e4a04d00] ref B L0: 59.5% 37.4%  3.1%
[libx264 @ 0x55f4e4a04d00] ref B L1: 97.5%  2.5%
[libx264 @ 0x55f4e4a04d00] kb/s:35.98
Exiting normally, received signal 2.
[ERR=255]


More information about the ffmpeg-user mailing list