[FFmpeg-trac] #10976(ffmpeg:new): ffmpeg/avfilter: multiple outputs with one having rarer output causes memory ballooning

FFmpeg trac at avcodec.org
Wed Apr 24 10:06:08 EEST 2024


#10976: ffmpeg/avfilter: multiple outputs with one having rarer output causes
memory ballooning
-------------------------------------+-------------------------------------
             Reporter:  jeeb         |                    Owner:  (none)
                 Type:  defect       |                   Status:  new
             Priority:  normal       |                Component:  ffmpeg
              Version:  unspecified  |               Resolution:
             Keywords:  avfilter     |               Blocked By:
  ffmpeg                             |
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
Description changed by jeeb:

Old description:

> Summary of the bug:
>
> Flagging this as both ffmpeg CLI as well as avfilter, as I am not sure
> which is the part that is the larger cause of this (ffmpeg CLI's API
> usage or the internals of avfilter's synchronization logic itself).
>
> After d119ae2fd82a494d9430ff4d4fc262961a68c598 , ffmpeg CLI started
> memory ballooning with an input as well as a filter chain where there is
> one output which provides less often than the other ones. Before this the
> test case would have a maximum resident set size of about 60 megabytes,
> while now the same test case shows buffering of 100 frames in the outputs
> which should be able to output more often and has a maximum resident set
> size of around 4 gigabytes.
>
> Thankfully, to reproduce this no specific input or output encoders or
> muxers are required.
>
> How to reproduce:
> {{{
> % /usr/bin/time -v \
>   ffmpeg -v verbose \
>   -f lavfi -i "testsrc2=r=24:d=10:s=1280x720" \
>   -filter_complex
> "[0:v]split=4[v0][v1][v2][thumb_in];[v0]scale=3840:2160[out0];[v1]scale=1920:1080[out1];[v2]scale=1280:720[out2];[thumb_in]select='eq(key\\,1)',fps=1/60:round=up:start_time=0[thumb_out]"
> \
>   -map '[out0]' -f null pipe: \
>   -map '[out1]' -f null pipe: \
>   -map '[out2]' -f null pipe: \
>   -map '[thumb_out]' -f null pipe:
>
> ffmpeg version N-114988-g8c62d77139 Copyright (c) 2000-2024 the FFmpeg
> developers
>   built with gcc 14 (GCC)
>   configuration: --prefix=/home/jeeb/ownapps/encoding_prefix/ --enable-
> static --disable-doc --disable-stripping --enable-gpl --enable-version3
> --enable-vaapi --enable-zlib --enable-libdav1d --enable-libx264 --enable-
> libsvtav1 --enable-libx265 --enable-libzimg --enable-gnutls --enable-
> libplacebo
>   libavutil      59. 16.100 / 59. 16.100
>   libavcodec     61.  5.103 / 61.  5.103
>   libavformat    61.  3.100 / 61.  3.100
>   libavdevice    61.  2.100 / 61.  2.100
>   libavfilter    10.  2.101 / 10.  2.101
>   libswscale      8.  2.100 /  8.  2.100
>   libswresample   5.  2.100 /  5.  2.100
>   libpostproc    58.  2.100 / 58.  2.100
> [Parsed_scale_1 @ 0x4e774c0] w:3840 h:2160 flags:'' interl:0
> [Parsed_scale_2 @ 0x4e84880] w:1920 h:1080 flags:'' interl:0
> [Parsed_scale_3 @ 0x4e91c40] w:1280 h:720 flags:'' interl:0
> [Parsed_fps_5 @ 0x4e9f380] 0 frames in, 0 frames out; 0 frames dropped, 0
> frames duplicated.
> [Parsed_testsrc2_0 @ 0x4e91c40] size:1280x720 rate:24/1
> duration:10.000000 sar:1/1
> Input #0, lavfi, from 'testsrc2=r=24:d=10:s=1280x720':
>   Duration: N/A, start: 0.000000, bitrate: N/A
>   Stream #0:0: Video: wrapped_avframe, 1 reference frame, yuv420p,
> 1280x720 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 24 tbn
> [out#0/null @ 0x4e75a40] Adding streams from explicit maps...
> [out#0/null @ 0x4e75a40] Creating output stream from an explicitly mapped
> complex filtergraph 0, output [out0]
> [vost#0:0/wrapped_avframe @ 0x4e89740] Created video stream from complex
> filtergraph 0:[scale:default]
> [vost#0:0/wrapped_avframe @ 0x4e89740]
> [out#1/null @ 0x4e89d40] Adding streams from explicit maps...
> [out#1/null @ 0x4e89d40] Creating output stream from an explicitly mapped
> complex filtergraph 0, output [out1]
> [vost#1:0/wrapped_avframe @ 0x4e8a780] Created video stream from complex
> filtergraph 0:[scale:default]
> [vost#1:0/wrapped_avframe @ 0x4e8a780]
> [out#2/null @ 0x4e8b540] Adding streams from explicit maps...
> [out#2/null @ 0x4e8b540] Creating output stream from an explicitly mapped
> complex filtergraph 0, output [out2]
> [vost#2:0/wrapped_avframe @ 0x4e8bfc0] Created video stream from complex
> filtergraph 0:[scale:default]
> [vost#2:0/wrapped_avframe @ 0x4e8bfc0]
> [out#3/null @ 0x4e8d040] Adding streams from explicit maps...
> [out#3/null @ 0x4e8d040] Creating output stream from an explicitly mapped
> complex filtergraph 0, output [thumb_out]
> [vost#3:0/wrapped_avframe @ 0x4e8db40] Created video stream from complex
> filtergraph 0:[fps:default]
> [vost#3:0/wrapped_avframe @ 0x4e8db40]
> [fc#0 @ 0x4e75440] Binding input with label '0:v' to input stream 0:0
> Stream mapping:
>   Stream #0:0 (wrapped_avframe) -> split:default
>   scale:default -> Stream #0:0 (wrapped_avframe)
>   scale:default -> Stream #1:0 (wrapped_avframe)
>   scale:default -> Stream #2:0 (wrapped_avframe)
>   fps:default -> Stream #3:0 (wrapped_avframe)
> [vost#0:0/wrapped_avframe @ 0x4e89740] Starting thread...
> [vost#1:0/wrapped_avframe @ 0x4e8a780] Starting thread...
> [vost#2:0/wrapped_avframe @ 0x4e8bfc0] Starting thread...
> [vost#3:0/wrapped_avframe @ 0x4e8db40] Starting thread...
> [fc#0 @ 0x4e75440] Starting thread...
> [vist#0:0/wrapped_avframe @ 0x4e88f40] [dec:wrapped_avframe @ 0x4e8f040]
> Starting thread...
> [in#0/lavfi @ 0x4e84b80] Starting thread...
> Press [q] to stop, [?] for help
> [Parsed_scale_1 @ 0x7fade4004d80] w:3840 h:2160 flags:'' interl:0
> [Parsed_scale_2 @ 0x7fade4012140] w:1920 h:1080 flags:'' interl:0
> [Parsed_scale_3 @ 0x7fade401f500] w:1280 h:720 flags:'' interl:0
> [graph 0 input from stream 0:0 @ 0x7fade40017c0] w:1280 h:720
> pixfmt:yuv420p tb:1/24 fr:24/1 sar:1/1 csp:unknown range:unknown
> [Parsed_scale_1 @ 0x7fade4004d80] w:1280 h:720 fmt:yuv420p csp:unknown
> range:unknown sar:1/1 -> w:3840 h:2160 fmt:yuv420p csp:unknown
> range:unknown sar:1/1 flags:0x00000004
> [Parsed_scale_2 @ 0x7fade4012140] w:1280 h:720 fmt:yuv420p csp:unknown
> range:unknown sar:1/1 -> w:1920 h:1080 fmt:yuv420p csp:unknown
> range:unknown sar:1/1 flags:0x00000004
> [Parsed_scale_3 @ 0x7fade401f500] w:1280 h:720 fmt:yuv420p csp:unknown
> range:unknown sar:1/1 -> w:1280 h:720 fmt:yuv420p csp:unknown
> range:unknown sar:1/1 flags:(null)
> [Parsed_fps_5 @ 0x7fade402cc40] Set first pts to (in:0 out:0) from start
> time 0.000000
> [Parsed_fps_5 @ 0x7fade402cc40] fps=1/60
> [graph 0 input from stream 0:0 @ 0x7fade40017c0] video frame properties
> congruent with link at pts_time: 0
> Output #0, null, to 'pipe:':
>   Metadata:
>     encoder         : Lavf61.3.100
>   Stream #0:0: Video: wrapped_avframe, 1 reference frame,
> yuv420p(progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24
> fps, 24 tbn
>       Metadata:
>         encoder         : Lavc61.5.103 wrapped_avframe
> [out#0/null @ 0x4e75a40] Starting thread...
> Output #1, null, to 'pipe:':
>   Metadata:
>     encoder         : Lavf61.3.100
>   Stream #1:0: Video: wrapped_avframe, 1 reference frame,
> yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24
> fps, 24 tbn
>       Metadata:
>         encoder         : Lavc61.5.103 wrapped_avframe
> [out#1/null @ 0x4e89d40] Starting thread...
> Output #2, null, to 'pipe:':
>   Metadata:
>     encoder         : Lavf61.3.100
>   Stream #2:0: Video: wrapped_avframe, 1 reference frame,
> yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24
> fps, 24 tbn
>       Metadata:
>         encoder         : Lavc61.5.103 wrapped_avframe
> [out#2/null @ 0x4e8b540] Starting thread...
> Output #3, null, to 'pipe:':
>   Metadata:
>     encoder         : Lavf61.3.100
>   Stream #3:0: Video: wrapped_avframe, 1 reference frame,
> yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 0.02
> fps, 0.02 tbn
>       Metadata:
>         encoder         : Lavc61.5.103 wrapped_avframe
> [out#3/null @ 0x4e8d040] Starting thread...
> [out_#0:0 @ 0x7fade4001540] 100 buffers queued in out_#0:0, something may
> be wrong./A speed=0.0833x
> [out_#1:0 @ 0x7fade402f8c0] 100 buffers queued in out_#1:0, something may
> be wrong.
> [out_#2:0 @ 0x7fade402fbc0] 100 buffers queued in out_#2:0, something may
> be wrong.
> [in#0/lavfi @ 0x4e84b80] EOF while reading inputsize=N/A time=00:00:00.08
> bitrate=N/A speed=0.0278x
> [in#0/lavfi @ 0x4e84b80] Terminating thread with return code 0 (success)
> [vist#0:0/wrapped_avframe @ 0x4e88f40] [dec:wrapped_avframe @ 0x4e8f040]
> Decoder thread received EOF packet
> [vist#0:0/wrapped_avframe @ 0x4e88f40] [dec:wrapped_avframe @ 0x4e8f040]
> Decoder returned EOF, finishing
> [vist#0:0/wrapped_avframe @ 0x4e88f40] [dec:wrapped_avframe @ 0x4e8f040]
> Terminating thread with return code 0 (success)
> [vost#0:0/wrapped_avframe @ 0x4e89740] Encoder thread received EOF
> [vost#0:0/wrapped_avframe @ 0x4e89740] Terminating thread with return
> code 0 (success)
> [out#0/null @ 0x4e75a40] All streams finished
> [out#0/null @ 0x4e75a40] Terminating thread with return code 0 (success)
> [vost#1:0/wrapped_avframe @ 0x4e8a780] Encoder thread received EOF
> [vost#1:0/wrapped_avframe @ 0x4e8a780] Terminating thread with return
> code 0 (success)
> [out#1/null @ 0x4e89d40] All streams finished
> [out#1/null @ 0x4e89d40] Terminating thread with return code 0 (success)
> [fc#0 @ 0x4e75440] Filtergraph returned EOF, finishing
> [fc#0 @ 0x4e75440] All consumers returned EOF
> [vost#3:0/wrapped_avframe @ 0x4e8db40] Encoder thread received EOF
> [vost#3:0/wrapped_avframe @ 0x4e8db40] Terminating thread with return
> code 0 (success)
> [vost#2:0/wrapped_avframe @ 0x4e8bfc0] Encoder thread received EOF
> [vost#2:0/wrapped_avframe @ 0x4e8bfc0] Terminating thread with return
> code 0 (success)
> [out#2/null @ 0x4e8b540] All streams finished
> [out#2/null @ 0x4e8b540] Terminating thread with return code 0 (success)
> [out#3/null @ 0x4e8d040] All streams finished
> [out#3/null @ 0x4e8d040] Terminating thread with return code 0 (success)
> [Parsed_fps_5 @ 0x7fade402cc40] 240 frames in, 1 frames out; 239 frames
> dropped, 0 frames duplicated.
> [fc#0 @ 0x4e75440] Terminating thread with return code 0 (success)
> [out#0/null @ 0x4e75a40] Output file #0 (pipe:):
> [out#0/null @ 0x4e75a40]   Output stream #0:0 (video): 240 frames
> encoded; 240 packets muxed (105600 bytes);
> [out#0/null @ 0x4e75a40]   Total: 240 packets (105600 bytes) muxed
> [out#0/null @ 0x4e75a40] video:103KiB audio:0KiB subtitle:0KiB other
> streams:0KiB global headers:0KiB muxing overhead: unknown
> [out#1/null @ 0x4e89d40] Output file #1 (pipe:):
> [out#1/null @ 0x4e89d40]   Output stream #1:0 (video): 240 frames
> encoded; 240 packets muxed (105600 bytes);
> [out#1/null @ 0x4e89d40]   Total: 240 packets (105600 bytes) muxed
> [out#1/null @ 0x4e89d40] video:103KiB audio:0KiB subtitle:0KiB other
> streams:0KiB global headers:0KiB muxing overhead: unknown
> [out#2/null @ 0x4e8b540] Output file #2 (pipe:):
> [out#2/null @ 0x4e8b540]   Output stream #2:0 (video): 240 frames
> encoded; 240 packets muxed (105600 bytes);
> [out#2/null @ 0x4e8b540]   Total: 240 packets (105600 bytes) muxed
> [out#2/null @ 0x4e8b540] video:103KiB audio:0KiB subtitle:0KiB other
> streams:0KiB global headers:0KiB muxing overhead: unknown
> [out#3/null @ 0x4e8d040] Output file #3 (pipe:):
> [out#3/null @ 0x4e8d040]   Output stream #3:0 (video): 1 frames encoded;
> 1 packets muxed (440 bytes);
> [out#3/null @ 0x4e8d040]   Total: 1 packets (440 bytes) muxed
> [out#3/null @ 0x4e8d040] video:0KiB audio:0KiB subtitle:0KiB other
> streams:0KiB global headers:0KiB muxing overhead: unknown
> frame=  240 fps= 65 q=-0.0 Lq=-0.0 q=-0.0 q=-0.0 size=N/A
> time=00:00:10.00 bitrate=N/A speed=2.69x
> [in#0/lavfi @ 0x4e84b80] Input file #0 (testsrc2=r=24:d=10:s=1280x720):
> [in#0/lavfi @ 0x4e84b80]   Input stream #0:0 (video): 240 packets read
> (105600 bytes); 240 frames decoded; 0 decode errors;
> [in#0/lavfi @ 0x4e84b80]   Total: 240 packets (105600 bytes) demuxed
>         Command being timed: "ffmpeg -v verbose -f lavfi -i
> testsrc2=r=24:d=10:s=1280x720 -filter_complex
> [0:v]split=4[v0][v1][v2][thumb_in];[v0]scale=3840:2160[out0];[v1]scale=1920:1080[out1];[v2]scale=1280:720[out2];[thumb_in]select='eq(key\,1)',fps=1/60:round=up:start_time=0[thumb_out]
> -map [out0] -f null pipe: -map [out1] -f null pipe: -map [out2] -f null
> pipe: -map [thumb_out] -f null pipe:"
>         User time (seconds): 6.88
>         System time (seconds): 3.20
>         Percent of CPU this job got: 266%
>         Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.78
>         Average shared text size (kbytes): 0
>         Average unshared data size (kbytes): 0
>         Average stack size (kbytes): 0
>         Average total size (kbytes): 0
>         Maximum resident set size (kbytes): 3992448
>         Average resident set size (kbytes): 0
>         Major (requiring I/O) page faults: 0
>         Minor (reclaiming a frame) page faults: 994857
>         Voluntary context switches: 9275
>         Involuntary context switches: 170
>         Swaps: 0
>         File system inputs: 0
>         File system outputs: 0
>         Socket messages sent: 0
>         Socket messages received: 0
>         Signals delivered: 0
>         Page size (bytes): 4096
>         Exit status: 0
> }}}
>
> While with commit d119ae2fd82a494d9430ff4d4fc262961a68c598~1
> (9b8cc36ce0b2417469d78c68780c8796886c202e), the output of the time binary
> is as follows:
>
> {{{
>         Command being timed: "ffmpeg -v verbose -f lavfi -i
> testsrc2=r=24:d=10:s=1280x720 -filter_complex
> [0:v]split=4[v0][v1][v2][thumb_in];[v0]scale=3840:2160[out0];[v1]scale=1920:1080[out1];[v2]scale=1280:720[out2];[thumb_in]select='eq(key\,1)',fps=1/60:round=up:start_time=0[thumb_out]
> -map [out0] -f null pipe: -map [out1] -f null pipe: -map [out2] -f null
> pipe: -map [thumb_out] -f null pipe:"
>         User time (seconds): 8.24
>         System time (seconds): 0.22
>         Percent of CPU this job got: 914%
>         Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.92
>         Average shared text size (kbytes): 0
>         Average unshared data size (kbytes): 0
>         Average stack size (kbytes): 0
>         Average total size (kbytes): 0
>         Maximum resident set size (kbytes): 60132
>         Average resident set size (kbytes): 0
>         Major (requiring I/O) page faults: 0
>         Minor (reclaiming a frame) page faults: 13281
>         Voluntary context switches: 12794
>         Involuntary context switches: 48
>         Swaps: 0
>         File system inputs: 0
>         File system outputs: 0
>         Socket messages sent: 0
>         Socket messages received: 0
>         Signals delivered: 0
>         Page size (bytes): 4096
>         Exit status: 0
> }}}
>
> **Note**:
>
> The underlying issue might be much older, and the ffmpeg CLI threading
> commit might have just made things more consistent. This is due to the
> fact that in case of there not being any actual inputs, but just the
> complex filter chain, this has been happening at least with release/2.0
> if not earlier (the test case started segfaulting at release/1.2, at
> which point I decided to start writing up this ticket).
>
> Example from the same version which has a maximum resident set size of
> ~60MiB when an input is involved:
>
> {{{
> % /usr/bin/time -v \
>   ffmpeg -v verbose \
>   -filter_complex
> "testsrc2=r=24:d=10:s=1280x720,split=4[v0][v1][v2][thumb_in];[v0]scale=3840:2160[out0];[v1]scale=1920:1080[out1];[v2]scale=1280:720[out2];[thumb_in]select='eq(key\\,1)',fps=1/60:round=up:start_time=0[thumb_out]"
> \
>   -map '[out0]' -f null pipe: \
>   -map '[out1]' -f null pipe: \
>   -map '[out2]' -f null pipe: \
>   -map '[thumb_out]' -f null pipe:
>
> ffmpeg version N-112958-g9b8cc36ce0 Copyright (c) 2000-2023 the FFmpeg
> developers
>   built with gcc 14 (GCC)
>   configuration: --prefix=/home/jeeb/ownapps/encoding_prefix/ --enable-
> static --disable-autodetect
>   libavutil      58. 32.100 / 58. 32.100
>   libavcodec     60. 35.100 / 60. 35.100
>   libavformat    60. 18.100 / 60. 18.100
>   libavdevice    60.  4.100 / 60.  4.100
>   libavfilter     9. 14.100 /  9. 14.100
>   libswscale      7.  6.100 /  7.  6.100
>   libswresample   4. 13.100 /  4. 13.100
> [Parsed_testsrc2_0 @ 0x3029a80] size:1280x720 rate:24/1
> duration:10.000000 sar:1/1
> [Parsed_scale_2 @ 0x302a100] w:3840 h:2160 flags:'' interl:0
> [Parsed_scale_3 @ 0x3037500] w:1920 h:1080 flags:'' interl:0
> [Parsed_scale_4 @ 0x3044900] w:1280 h:720 flags:'' interl:0
> [Parsed_fps_6 @ 0x30520c0] 0 frames in, 0 frames out; 0 frames dropped, 0
> frames duplicated.
> [out#0/null @ 0x3029580] Adding streams from explicit maps...
> [out#0/null @ 0x3029580] Creating output stream from an explicitly mapped
> complex filtergraph 0, output [out0]
> [vost#0:0/wrapped_avframe @ 0x3038200] Created video stream from complex
> filtergraph 0:[scale:default]
> [vost#0:0/wrapped_avframe @ 0x3038200]
> [out#1/null @ 0x30525c0] Adding streams from explicit maps...
> [out#1/null @ 0x30525c0] Creating output stream from an explicitly mapped
> complex filtergraph 0, output [out1]
> [vost#1:0/wrapped_avframe @ 0x30397c0] Created video stream from complex
> filtergraph 0:[scale:default]
> [vost#1:0/wrapped_avframe @ 0x30397c0]
> [out#2/null @ 0x303a580] Adding streams from explicit maps...
> [out#2/null @ 0x303a580] Creating output stream from an explicitly mapped
> complex filtergraph 0, output [out2]
> [vost#2:0/wrapped_avframe @ 0x303b480] Created video stream from complex
> filtergraph 0:[scale:default]
> [vost#2:0/wrapped_avframe @ 0x303b480]
> [out#3/null @ 0x303c380] Adding streams from explicit maps...
> [out#3/null @ 0x303c380] Creating output stream from an explicitly mapped
> complex filtergraph 0, output [thumb_out]
> [vost#3:0/wrapped_avframe @ 0x303d2c0] Created video stream from complex
> filtergraph 0:[fps:default]
> [vost#3:0/wrapped_avframe @ 0x303d2c0]
> Stream mapping:
>   scale:default -> Stream #0:0 (wrapped_avframe)
>   scale:default -> Stream #1:0 (wrapped_avframe)
>   scale:default -> Stream #2:0 (wrapped_avframe)
>   fps:default -> Stream #3:0 (wrapped_avframe)
> Press [q] to stop, [?] for help
> [Parsed_testsrc2_0 @ 0x7f2d9c004240] size:1280x720 rate:24/1
> duration:10.000000 sar:1/1
> [Parsed_scale_2 @ 0x7f2d9c0048c0] w:3840 h:2160 flags:'' interl:0
> [Parsed_scale_3 @ 0x7f2d9c011cc0] w:1920 h:1080 flags:'' interl:0
> [Parsed_scale_4 @ 0x7f2d9c01f0c0] w:1280 h:720 flags:'' interl:0
> [Parsed_scale_2 @ 0x7f2d9c0048c0] w:1280 h:720 fmt:yuv420p sar:1/1 ->
> w:3840 h:2160 fmt:yuv420p sar:1/1 flags:0x00000004
> [Parsed_scale_3 @ 0x7f2d9c011cc0] w:1280 h:720 fmt:yuv420p sar:1/1 ->
> w:1920 h:1080 fmt:yuv420p sar:1/1 flags:0x00000004
> [Parsed_scale_4 @ 0x7f2d9c01f0c0] w:1280 h:720 fmt:yuv420p sar:1/1 ->
> w:1280 h:720 fmt:yuv420p sar:1/1 flags:(null)
> [Parsed_fps_6 @ 0x7f2d9c02c880] Set first pts to (in:0 out:0) from start
> time 0.000000
> [Parsed_fps_6 @ 0x7f2d9c02c880] fps=1/60
> Output #0, null, to 'pipe:':
>   Metadata:
>     encoder         : Lavf60.18.100
>   Stream #0:0: Video: wrapped_avframe, 1 reference frame, yuv420p(tv,
> progressive), 3840x2160 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24
> fps, 24 tbn
>     Metadata:
>       encoder         : Lavc60.35.100 wrapped_avframe
> Output #1, null, to 'pipe:':
>   Metadata:
>     encoder         : Lavf60.18.100
>   Stream #1:0: Video: wrapped_avframe, 1 reference frame, yuv420p(tv,
> progressive), 1920x1080 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24
> fps, 24 tbn
>     Metadata:
>       encoder         : Lavc60.35.100 wrapped_avframe
> Output #2, null, to 'pipe:':
>   Metadata:
>     encoder         : Lavf60.18.100
>   Stream #2:0: Video: wrapped_avframe, 1 reference frame,
> yuv420p(progressive), 1280x720 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 200
> kb/s, 24 fps, 24 tbn
>     Metadata:
>       encoder         : Lavc60.35.100 wrapped_avframe
> Output #3, null, to 'pipe:':
>   Metadata:
>     encoder         : Lavf60.18.100
>   Stream #3:0: Video: wrapped_avframe, 1 reference frame,
> yuv420p(progressive), 1280x720 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 200
> kb/s, 0.02 fps, 0.02 tbn
>     Metadata:
>       encoder         : Lavc60.35.100 wrapped_avframe
> [out_0_0 @ 0x7f2d9c001840] 100 buffers queued in out_0_0, something may
> be wrong.=N/A speed=0.683x
> [out_1_0 @ 0x7f2d9c001700] 100 buffers queued in out_1_0, something may
> be wrong.
> [out_2_0 @ 0x7f2d9c0015c0] 100 buffers queued in out_2_0, something may
> be wrong.
> [fc#0 @ 0x3027980] Terminating filtering thread
> No more output streams to write to, finishing.0 size=N/A time=00:00:09.95
> bitrate=N/A speed=2.77x
> [vost#0:0/wrapped_avframe @ 0x3038200] Encoder thread received EOF
> [vost#0:0/wrapped_avframe @ 0x3038200] Encoder returned EOF, finishing
> [vost#0:0/wrapped_avframe @ 0x3038200] Terminating encoder thread
> [out#0/null @ 0x3029580] All streams finished
> [out#0/null @ 0x3029580] Terminating muxer thread
> [vost#1:0/wrapped_avframe @ 0x30397c0] Encoder thread received EOF
> [vost#1:0/wrapped_avframe @ 0x30397c0] Encoder returned EOF, finishing
> [vost#1:0/wrapped_avframe @ 0x30397c0] Terminating encoder thread
> [vost#2:0/wrapped_avframe @ 0x303b480] Encoder thread received EOF
> [vost#2:0/wrapped_avframe @ 0x303b480] Encoder returned EOF, finishing
> [vost#2:0/wrapped_avframe @ 0x303b480] Terminating encoder thread
> [out#1/null @ 0x30525c0] All streams finished
> [out#1/null @ 0x30525c0] Terminating muxer thread
> [out#2/null @ 0x303a580] All streams finished
> [out#2/null @ 0x303a580] Terminating muxer thread
> [vost#3:0/wrapped_avframe @ 0x303d2c0] Encoder thread received EOF
> [vost#3:0/wrapped_avframe @ 0x303d2c0] Encoder returned EOF, finishing
> [vost#3:0/wrapped_avframe @ 0x303d2c0] Terminating encoder thread
> [out#3/null @ 0x303c380] All streams finished
> [out#3/null @ 0x303c380] Terminating muxer thread
> [out#0/null @ 0x3029580] Output file #0 (pipe:):
> [out#0/null @ 0x3029580]   Output stream #0:0 (video): 240 frames
> encoded; 240 packets muxed (115200 bytes);
> [out#0/null @ 0x3029580]   Total: 240 packets (115200 bytes) muxed
> [out#0/null @ 0x3029580] video:112kB audio:0kB subtitle:0kB other
> streams:0kB global headers:0kB muxing overhead: unknown
> [out#1/null @ 0x30525c0] Output file #1 (pipe:):
> [out#1/null @ 0x30525c0]   Output stream #1:0 (video): 240 frames
> encoded; 240 packets muxed (115200 bytes);
> [out#1/null @ 0x30525c0]   Total: 240 packets (115200 bytes) muxed
> [out#1/null @ 0x30525c0] video:112kB audio:0kB subtitle:0kB other
> streams:0kB global headers:0kB muxing overhead: unknown
> [out#2/null @ 0x303a580] Output file #2 (pipe:):
> [out#2/null @ 0x303a580]   Output stream #2:0 (video): 240 frames
> encoded; 240 packets muxed (115200 bytes);
> [out#2/null @ 0x303a580]   Total: 240 packets (115200 bytes) muxed
> [out#2/null @ 0x303a580] video:112kB audio:0kB subtitle:0kB other
> streams:0kB global headers:0kB muxing overhead: unknown
> [out#3/null @ 0x303c380] Output file #3 (pipe:):
> [out#3/null @ 0x303c380]   Output stream #3:0 (video): 1 frames encoded;
> 1 packets muxed (480 bytes);
> [out#3/null @ 0x303c380]   Total: 1 packets (480 bytes) muxed
> [out#3/null @ 0x303c380] video:0kB audio:0kB subtitle:0kB other
> streams:0kB global headers:0kB muxing overhead: unknown
> frame=  240 fps= 67 q=-0.0 Lq=-0.0 q=-0.0 q=-0.0 size=N/A
> time=00:00:09.95 bitrate=N/A speed=2.77x
> [Parsed_fps_6 @ 0x7f2d9c02c880] 240 frames in, 1 frames out; 239 frames
> dropped, 0 frames duplicated.
>         Command being timed: "ffmpeg -v verbose -filter_complex
> testsrc2=r=24:d=10:s=1280x720,split=4[v0][v1][v2][thumb_in];[v0]scale=3840:2160[out0];[v1]scale=1920:1080[out1];[v2]scale=1280:720[out2];[thumb_in]select='eq(key\,1)',fps=1/60:round=up:start_time=0[thumb_out]
> -map [out0] -f null pipe: -map [out1] -f null pipe: -map [out2] -f null
> pipe: -map [thumb_out] -f null pipe:"
>         User time (seconds): 6.46
>         System time (seconds): 3.02
>         Percent of CPU this job got: 230%
>         Elapsed (wall clock) time (h:mm:ss or m:ss): 0:04.11
>         Average shared text size (kbytes): 0
>         Average unshared data size (kbytes): 0
>         Average stack size (kbytes): 0
>         Average total size (kbytes): 0
>         Maximum resident set size (kbytes): 3983600
>         Average resident set size (kbytes): 0
>         Major (requiring I/O) page faults: 0
>         Minor (reclaiming a frame) page faults: 994229
>         Voluntary context switches: 10705
>         Involuntary context switches: 144
>         Swaps: 0
>         File system inputs: 0
>         File system outputs: 0
>         Socket messages sent: 0
>         Socket messages received: 0
>         Signals delivered: 0
>         Page size (bytes): 4096
>         Exit status: 0
> }}}

New description:

 Summary of the bug:

 Flagging this as both ffmpeg CLI as well as avfilter, as I am not sure
 which is the part that is the larger cause of this (ffmpeg CLI's API usage
 or the internals of avfilter's synchronization logic itself).

 After d119ae2fd82a494d9430ff4d4fc262961a68c598 , ffmpeg CLI started memory
 ballooning with an input as well as a filter chain where there is one
 output which provides less often than the other ones. Before this the test
 case would have a maximum resident set size of about 60 megabytes, while
 now the same test case shows buffering of 100 frames in the outputs which
 should be able to output more often and has a maximum resident set size of
 around 4 gigabytes.

 Thankfully, to reproduce this no specific input or output encoders or
 muxers are required.

 How to reproduce:
 {{{
 % /usr/bin/time -v \
   ffmpeg -v verbose \
   -f lavfi -i "testsrc2=r=24:d=10:s=1280x720" \
   -filter_complex
 "[0:v]split=4[v0][v1][v2][thumb_in];[v0]scale=3840:2160[out0];[v1]scale=1920:1080[out1];[v2]scale=1280:720[out2];[thumb_in]fps=1/60:round=up:start_time=0[thumb_out]"
 \
   -map '[out0]' -f null pipe: \
   -map '[out1]' -f null pipe: \
   -map '[out2]' -f null pipe: \
   -map '[thumb_out]' -f null pipe:

 ffmpeg version N-114988-g8c62d77139 Copyright (c) 2000-2024 the FFmpeg
 developers
   built with gcc 14 (GCC)
   configuration: --prefix=/home/jeeb/ownapps/encoding_prefix/ --enable-
 static --disable-doc --disable-stripping --enable-gpl --enable-version3
 --enable-vaapi --enable-zlib --enable-libdav1d --enable-libx264 --enable-
 libsvtav1 --enable-libx265 --enable-libzimg --enable-gnutls --enable-
 libplacebo
   libavutil      59. 16.100 / 59. 16.100
   libavcodec     61.  5.103 / 61.  5.103
   libavformat    61.  3.100 / 61.  3.100
   libavdevice    61.  2.100 / 61.  2.100
   libavfilter    10.  2.101 / 10.  2.101
   libswscale      8.  2.100 /  8.  2.100
   libswresample   5.  2.100 /  5.  2.100
   libpostproc    58.  2.100 / 58.  2.100
 [Parsed_scale_1 @ 0x4e774c0] w:3840 h:2160 flags:'' interl:0
 [Parsed_scale_2 @ 0x4e84880] w:1920 h:1080 flags:'' interl:0
 [Parsed_scale_3 @ 0x4e91c40] w:1280 h:720 flags:'' interl:0
 [Parsed_fps_5 @ 0x4e9f380] 0 frames in, 0 frames out; 0 frames dropped, 0
 frames duplicated.
 [Parsed_testsrc2_0 @ 0x4e91c40] size:1280x720 rate:24/1 duration:10.000000
 sar:1/1
 Input #0, lavfi, from 'testsrc2=r=24:d=10:s=1280x720':
   Duration: N/A, start: 0.000000, bitrate: N/A
   Stream #0:0: Video: wrapped_avframe, 1 reference frame, yuv420p,
 1280x720 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 24 tbn
 [out#0/null @ 0x4e75a40] Adding streams from explicit maps...
 [out#0/null @ 0x4e75a40] Creating output stream from an explicitly mapped
 complex filtergraph 0, output [out0]
 [vost#0:0/wrapped_avframe @ 0x4e89740] Created video stream from complex
 filtergraph 0:[scale:default]
 [vost#0:0/wrapped_avframe @ 0x4e89740]
 [out#1/null @ 0x4e89d40] Adding streams from explicit maps...
 [out#1/null @ 0x4e89d40] Creating output stream from an explicitly mapped
 complex filtergraph 0, output [out1]
 [vost#1:0/wrapped_avframe @ 0x4e8a780] Created video stream from complex
 filtergraph 0:[scale:default]
 [vost#1:0/wrapped_avframe @ 0x4e8a780]
 [out#2/null @ 0x4e8b540] Adding streams from explicit maps...
 [out#2/null @ 0x4e8b540] Creating output stream from an explicitly mapped
 complex filtergraph 0, output [out2]
 [vost#2:0/wrapped_avframe @ 0x4e8bfc0] Created video stream from complex
 filtergraph 0:[scale:default]
 [vost#2:0/wrapped_avframe @ 0x4e8bfc0]
 [out#3/null @ 0x4e8d040] Adding streams from explicit maps...
 [out#3/null @ 0x4e8d040] Creating output stream from an explicitly mapped
 complex filtergraph 0, output [thumb_out]
 [vost#3:0/wrapped_avframe @ 0x4e8db40] Created video stream from complex
 filtergraph 0:[fps:default]
 [vost#3:0/wrapped_avframe @ 0x4e8db40]
 [fc#0 @ 0x4e75440] Binding input with label '0:v' to input stream 0:0
 Stream mapping:
   Stream #0:0 (wrapped_avframe) -> split:default
   scale:default -> Stream #0:0 (wrapped_avframe)
   scale:default -> Stream #1:0 (wrapped_avframe)
   scale:default -> Stream #2:0 (wrapped_avframe)
   fps:default -> Stream #3:0 (wrapped_avframe)
 [vost#0:0/wrapped_avframe @ 0x4e89740] Starting thread...
 [vost#1:0/wrapped_avframe @ 0x4e8a780] Starting thread...
 [vost#2:0/wrapped_avframe @ 0x4e8bfc0] Starting thread...
 [vost#3:0/wrapped_avframe @ 0x4e8db40] Starting thread...
 [fc#0 @ 0x4e75440] Starting thread...
 [vist#0:0/wrapped_avframe @ 0x4e88f40] [dec:wrapped_avframe @ 0x4e8f040]
 Starting thread...
 [in#0/lavfi @ 0x4e84b80] Starting thread...
 Press [q] to stop, [?] for help
 [Parsed_scale_1 @ 0x7fade4004d80] w:3840 h:2160 flags:'' interl:0
 [Parsed_scale_2 @ 0x7fade4012140] w:1920 h:1080 flags:'' interl:0
 [Parsed_scale_3 @ 0x7fade401f500] w:1280 h:720 flags:'' interl:0
 [graph 0 input from stream 0:0 @ 0x7fade40017c0] w:1280 h:720
 pixfmt:yuv420p tb:1/24 fr:24/1 sar:1/1 csp:unknown range:unknown
 [Parsed_scale_1 @ 0x7fade4004d80] w:1280 h:720 fmt:yuv420p csp:unknown
 range:unknown sar:1/1 -> w:3840 h:2160 fmt:yuv420p csp:unknown
 range:unknown sar:1/1 flags:0x00000004
 [Parsed_scale_2 @ 0x7fade4012140] w:1280 h:720 fmt:yuv420p csp:unknown
 range:unknown sar:1/1 -> w:1920 h:1080 fmt:yuv420p csp:unknown
 range:unknown sar:1/1 flags:0x00000004
 [Parsed_scale_3 @ 0x7fade401f500] w:1280 h:720 fmt:yuv420p csp:unknown
 range:unknown sar:1/1 -> w:1280 h:720 fmt:yuv420p csp:unknown
 range:unknown sar:1/1 flags:(null)
 [Parsed_fps_5 @ 0x7fade402cc40] Set first pts to (in:0 out:0) from start
 time 0.000000
 [Parsed_fps_5 @ 0x7fade402cc40] fps=1/60
 [graph 0 input from stream 0:0 @ 0x7fade40017c0] video frame properties
 congruent with link at pts_time: 0
 Output #0, null, to 'pipe:':
   Metadata:
     encoder         : Lavf61.3.100
   Stream #0:0: Video: wrapped_avframe, 1 reference frame,
 yuv420p(progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24
 fps, 24 tbn
       Metadata:
         encoder         : Lavc61.5.103 wrapped_avframe
 [out#0/null @ 0x4e75a40] Starting thread...
 Output #1, null, to 'pipe:':
   Metadata:
     encoder         : Lavf61.3.100
   Stream #1:0: Video: wrapped_avframe, 1 reference frame,
 yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24
 fps, 24 tbn
       Metadata:
         encoder         : Lavc61.5.103 wrapped_avframe
 [out#1/null @ 0x4e89d40] Starting thread...
 Output #2, null, to 'pipe:':
   Metadata:
     encoder         : Lavf61.3.100
   Stream #2:0: Video: wrapped_avframe, 1 reference frame,
 yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24
 fps, 24 tbn
       Metadata:
         encoder         : Lavc61.5.103 wrapped_avframe
 [out#2/null @ 0x4e8b540] Starting thread...
 Output #3, null, to 'pipe:':
   Metadata:
     encoder         : Lavf61.3.100
   Stream #3:0: Video: wrapped_avframe, 1 reference frame,
 yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 0.02
 fps, 0.02 tbn
       Metadata:
         encoder         : Lavc61.5.103 wrapped_avframe
 [out#3/null @ 0x4e8d040] Starting thread...
 [out_#0:0 @ 0x7fade4001540] 100 buffers queued in out_#0:0, something may
 be wrong./A speed=0.0833x
 [out_#1:0 @ 0x7fade402f8c0] 100 buffers queued in out_#1:0, something may
 be wrong.
 [out_#2:0 @ 0x7fade402fbc0] 100 buffers queued in out_#2:0, something may
 be wrong.
 [in#0/lavfi @ 0x4e84b80] EOF while reading inputsize=N/A time=00:00:00.08
 bitrate=N/A speed=0.0278x
 [in#0/lavfi @ 0x4e84b80] Terminating thread with return code 0 (success)
 [vist#0:0/wrapped_avframe @ 0x4e88f40] [dec:wrapped_avframe @ 0x4e8f040]
 Decoder thread received EOF packet
 [vist#0:0/wrapped_avframe @ 0x4e88f40] [dec:wrapped_avframe @ 0x4e8f040]
 Decoder returned EOF, finishing
 [vist#0:0/wrapped_avframe @ 0x4e88f40] [dec:wrapped_avframe @ 0x4e8f040]
 Terminating thread with return code 0 (success)
 [vost#0:0/wrapped_avframe @ 0x4e89740] Encoder thread received EOF
 [vost#0:0/wrapped_avframe @ 0x4e89740] Terminating thread with return code
 0 (success)
 [out#0/null @ 0x4e75a40] All streams finished
 [out#0/null @ 0x4e75a40] Terminating thread with return code 0 (success)
 [vost#1:0/wrapped_avframe @ 0x4e8a780] Encoder thread received EOF
 [vost#1:0/wrapped_avframe @ 0x4e8a780] Terminating thread with return code
 0 (success)
 [out#1/null @ 0x4e89d40] All streams finished
 [out#1/null @ 0x4e89d40] Terminating thread with return code 0 (success)
 [fc#0 @ 0x4e75440] Filtergraph returned EOF, finishing
 [fc#0 @ 0x4e75440] All consumers returned EOF
 [vost#3:0/wrapped_avframe @ 0x4e8db40] Encoder thread received EOF
 [vost#3:0/wrapped_avframe @ 0x4e8db40] Terminating thread with return code
 0 (success)
 [vost#2:0/wrapped_avframe @ 0x4e8bfc0] Encoder thread received EOF
 [vost#2:0/wrapped_avframe @ 0x4e8bfc0] Terminating thread with return code
 0 (success)
 [out#2/null @ 0x4e8b540] All streams finished
 [out#2/null @ 0x4e8b540] Terminating thread with return code 0 (success)
 [out#3/null @ 0x4e8d040] All streams finished
 [out#3/null @ 0x4e8d040] Terminating thread with return code 0 (success)
 [Parsed_fps_5 @ 0x7fade402cc40] 240 frames in, 1 frames out; 239 frames
 dropped, 0 frames duplicated.
 [fc#0 @ 0x4e75440] Terminating thread with return code 0 (success)
 [out#0/null @ 0x4e75a40] Output file #0 (pipe:):
 [out#0/null @ 0x4e75a40]   Output stream #0:0 (video): 240 frames encoded;
 240 packets muxed (105600 bytes);
 [out#0/null @ 0x4e75a40]   Total: 240 packets (105600 bytes) muxed
 [out#0/null @ 0x4e75a40] video:103KiB audio:0KiB subtitle:0KiB other
 streams:0KiB global headers:0KiB muxing overhead: unknown
 [out#1/null @ 0x4e89d40] Output file #1 (pipe:):
 [out#1/null @ 0x4e89d40]   Output stream #1:0 (video): 240 frames encoded;
 240 packets muxed (105600 bytes);
 [out#1/null @ 0x4e89d40]   Total: 240 packets (105600 bytes) muxed
 [out#1/null @ 0x4e89d40] video:103KiB audio:0KiB subtitle:0KiB other
 streams:0KiB global headers:0KiB muxing overhead: unknown
 [out#2/null @ 0x4e8b540] Output file #2 (pipe:):
 [out#2/null @ 0x4e8b540]   Output stream #2:0 (video): 240 frames encoded;
 240 packets muxed (105600 bytes);
 [out#2/null @ 0x4e8b540]   Total: 240 packets (105600 bytes) muxed
 [out#2/null @ 0x4e8b540] video:103KiB audio:0KiB subtitle:0KiB other
 streams:0KiB global headers:0KiB muxing overhead: unknown
 [out#3/null @ 0x4e8d040] Output file #3 (pipe:):
 [out#3/null @ 0x4e8d040]   Output stream #3:0 (video): 1 frames encoded; 1
 packets muxed (440 bytes);
 [out#3/null @ 0x4e8d040]   Total: 1 packets (440 bytes) muxed
 [out#3/null @ 0x4e8d040] video:0KiB audio:0KiB subtitle:0KiB other
 streams:0KiB global headers:0KiB muxing overhead: unknown
 frame=  240 fps= 65 q=-0.0 Lq=-0.0 q=-0.0 q=-0.0 size=N/A time=00:00:10.00
 bitrate=N/A speed=2.69x
 [in#0/lavfi @ 0x4e84b80] Input file #0 (testsrc2=r=24:d=10:s=1280x720):
 [in#0/lavfi @ 0x4e84b80]   Input stream #0:0 (video): 240 packets read
 (105600 bytes); 240 frames decoded; 0 decode errors;
 [in#0/lavfi @ 0x4e84b80]   Total: 240 packets (105600 bytes) demuxed
         Command being timed: "ffmpeg -v verbose -f lavfi -i
 testsrc2=r=24:d=10:s=1280x720 -filter_complex
 [0:v]split=4[v0][v1][v2][thumb_in];[v0]scale=3840:2160[out0];[v1]scale=1920:1080[out1];[v2]scale=1280:720[out2];[thumb_in]fps=1/60:round=up:start_time=0[thumb_out]
 -map [out0] -f null pipe: -map [out1] -f null pipe: -map [out2] -f null
 pipe: -map [thumb_out] -f null pipe:"
         User time (seconds): 6.88
         System time (seconds): 3.20
         Percent of CPU this job got: 266%
         Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.78
         Average shared text size (kbytes): 0
         Average unshared data size (kbytes): 0
         Average stack size (kbytes): 0
         Average total size (kbytes): 0
         Maximum resident set size (kbytes): 3992448
         Average resident set size (kbytes): 0
         Major (requiring I/O) page faults: 0
         Minor (reclaiming a frame) page faults: 994857
         Voluntary context switches: 9275
         Involuntary context switches: 170
         Swaps: 0
         File system inputs: 0
         File system outputs: 0
         Socket messages sent: 0
         Socket messages received: 0
         Signals delivered: 0
         Page size (bytes): 4096
         Exit status: 0
 }}}

 While with commit d119ae2fd82a494d9430ff4d4fc262961a68c598~1
 (9b8cc36ce0b2417469d78c68780c8796886c202e), the output of the time binary
 is as follows:

 {{{
         Command being timed: "ffmpeg -v verbose -f lavfi -i
 testsrc2=r=24:d=10:s=1280x720 -filter_complex
 [0:v]split=4[v0][v1][v2][thumb_in];[v0]scale=3840:2160[out0];[v1]scale=1920:1080[out1];[v2]scale=1280:720[out2];[thumb_in]fps=1/60:round=up:start_time=0[thumb_out]
 -map [out0] -f null pipe: -map [out1] -f null pipe: -map [out2] -f null
 pipe: -map [thumb_out] -f null pipe:"
         User time (seconds): 8.24
         System time (seconds): 0.22
         Percent of CPU this job got: 914%
         Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.92
         Average shared text size (kbytes): 0
         Average unshared data size (kbytes): 0
         Average stack size (kbytes): 0
         Average total size (kbytes): 0
         Maximum resident set size (kbytes): 60132
         Average resident set size (kbytes): 0
         Major (requiring I/O) page faults: 0
         Minor (reclaiming a frame) page faults: 13281
         Voluntary context switches: 12794
         Involuntary context switches: 48
         Swaps: 0
         File system inputs: 0
         File system outputs: 0
         Socket messages sent: 0
         Socket messages received: 0
         Signals delivered: 0
         Page size (bytes): 4096
         Exit status: 0
 }}}

 **Note**:

 The underlying issue might be much older, and the ffmpeg CLI threading
 commit might have just made things more consistent. This is due to the
 fact that in case of there not being any actual inputs, but just the
 complex filter chain, this has been happening at least with release/2.0 if
 not earlier (the test case started segfaulting at release/1.2, at which
 point I decided to start writing up this ticket).

 Example from the same version which has a maximum resident set size of
 ~60MiB when an input is involved:

 {{{
 % /usr/bin/time -v \
   ffmpeg -v verbose \
   -filter_complex
 "testsrc2=r=24:d=10:s=1280x720,split=4[v0][v1][v2][thumb_in];[v0]scale=3840:2160[out0];[v1]scale=1920:1080[out1];[v2]scale=1280:720[out2];[thumb_in]fps=1/60:round=up:start_time=0[thumb_out]"
 \
   -map '[out0]' -f null pipe: \
   -map '[out1]' -f null pipe: \
   -map '[out2]' -f null pipe: \
   -map '[thumb_out]' -f null pipe:

 ffmpeg version N-112958-g9b8cc36ce0 Copyright (c) 2000-2023 the FFmpeg
 developers
   built with gcc 14 (GCC)
   configuration: --prefix=/home/jeeb/ownapps/encoding_prefix/ --enable-
 static --disable-autodetect
   libavutil      58. 32.100 / 58. 32.100
   libavcodec     60. 35.100 / 60. 35.100
   libavformat    60. 18.100 / 60. 18.100
   libavdevice    60.  4.100 / 60.  4.100
   libavfilter     9. 14.100 /  9. 14.100
   libswscale      7.  6.100 /  7.  6.100
   libswresample   4. 13.100 /  4. 13.100
 [Parsed_testsrc2_0 @ 0x3029a80] size:1280x720 rate:24/1 duration:10.000000
 sar:1/1
 [Parsed_scale_2 @ 0x302a100] w:3840 h:2160 flags:'' interl:0
 [Parsed_scale_3 @ 0x3037500] w:1920 h:1080 flags:'' interl:0
 [Parsed_scale_4 @ 0x3044900] w:1280 h:720 flags:'' interl:0
 [Parsed_fps_6 @ 0x30520c0] 0 frames in, 0 frames out; 0 frames dropped, 0
 frames duplicated.
 [out#0/null @ 0x3029580] Adding streams from explicit maps...
 [out#0/null @ 0x3029580] Creating output stream from an explicitly mapped
 complex filtergraph 0, output [out0]
 [vost#0:0/wrapped_avframe @ 0x3038200] Created video stream from complex
 filtergraph 0:[scale:default]
 [vost#0:0/wrapped_avframe @ 0x3038200]
 [out#1/null @ 0x30525c0] Adding streams from explicit maps...
 [out#1/null @ 0x30525c0] Creating output stream from an explicitly mapped
 complex filtergraph 0, output [out1]
 [vost#1:0/wrapped_avframe @ 0x30397c0] Created video stream from complex
 filtergraph 0:[scale:default]
 [vost#1:0/wrapped_avframe @ 0x30397c0]
 [out#2/null @ 0x303a580] Adding streams from explicit maps...
 [out#2/null @ 0x303a580] Creating output stream from an explicitly mapped
 complex filtergraph 0, output [out2]
 [vost#2:0/wrapped_avframe @ 0x303b480] Created video stream from complex
 filtergraph 0:[scale:default]
 [vost#2:0/wrapped_avframe @ 0x303b480]
 [out#3/null @ 0x303c380] Adding streams from explicit maps...
 [out#3/null @ 0x303c380] Creating output stream from an explicitly mapped
 complex filtergraph 0, output [thumb_out]
 [vost#3:0/wrapped_avframe @ 0x303d2c0] Created video stream from complex
 filtergraph 0:[fps:default]
 [vost#3:0/wrapped_avframe @ 0x303d2c0]
 Stream mapping:
   scale:default -> Stream #0:0 (wrapped_avframe)
   scale:default -> Stream #1:0 (wrapped_avframe)
   scale:default -> Stream #2:0 (wrapped_avframe)
   fps:default -> Stream #3:0 (wrapped_avframe)
 Press [q] to stop, [?] for help
 [Parsed_testsrc2_0 @ 0x7f2d9c004240] size:1280x720 rate:24/1
 duration:10.000000 sar:1/1
 [Parsed_scale_2 @ 0x7f2d9c0048c0] w:3840 h:2160 flags:'' interl:0
 [Parsed_scale_3 @ 0x7f2d9c011cc0] w:1920 h:1080 flags:'' interl:0
 [Parsed_scale_4 @ 0x7f2d9c01f0c0] w:1280 h:720 flags:'' interl:0
 [Parsed_scale_2 @ 0x7f2d9c0048c0] w:1280 h:720 fmt:yuv420p sar:1/1 ->
 w:3840 h:2160 fmt:yuv420p sar:1/1 flags:0x00000004
 [Parsed_scale_3 @ 0x7f2d9c011cc0] w:1280 h:720 fmt:yuv420p sar:1/1 ->
 w:1920 h:1080 fmt:yuv420p sar:1/1 flags:0x00000004
 [Parsed_scale_4 @ 0x7f2d9c01f0c0] w:1280 h:720 fmt:yuv420p sar:1/1 ->
 w:1280 h:720 fmt:yuv420p sar:1/1 flags:(null)
 [Parsed_fps_6 @ 0x7f2d9c02c880] Set first pts to (in:0 out:0) from start
 time 0.000000
 [Parsed_fps_6 @ 0x7f2d9c02c880] fps=1/60
 Output #0, null, to 'pipe:':
   Metadata:
     encoder         : Lavf60.18.100
   Stream #0:0: Video: wrapped_avframe, 1 reference frame, yuv420p(tv,
 progressive), 3840x2160 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24
 fps, 24 tbn
     Metadata:
       encoder         : Lavc60.35.100 wrapped_avframe
 Output #1, null, to 'pipe:':
   Metadata:
     encoder         : Lavf60.18.100
   Stream #1:0: Video: wrapped_avframe, 1 reference frame, yuv420p(tv,
 progressive), 1920x1080 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 24
 fps, 24 tbn
     Metadata:
       encoder         : Lavc60.35.100 wrapped_avframe
 Output #2, null, to 'pipe:':
   Metadata:
     encoder         : Lavf60.18.100
   Stream #2:0: Video: wrapped_avframe, 1 reference frame,
 yuv420p(progressive), 1280x720 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s,
 24 fps, 24 tbn
     Metadata:
       encoder         : Lavc60.35.100 wrapped_avframe
 Output #3, null, to 'pipe:':
   Metadata:
     encoder         : Lavf60.18.100
   Stream #3:0: Video: wrapped_avframe, 1 reference frame,
 yuv420p(progressive), 1280x720 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s,
 0.02 fps, 0.02 tbn
     Metadata:
       encoder         : Lavc60.35.100 wrapped_avframe
 [out_0_0 @ 0x7f2d9c001840] 100 buffers queued in out_0_0, something may be
 wrong.=N/A speed=0.683x
 [out_1_0 @ 0x7f2d9c001700] 100 buffers queued in out_1_0, something may be
 wrong.
 [out_2_0 @ 0x7f2d9c0015c0] 100 buffers queued in out_2_0, something may be
 wrong.
 [fc#0 @ 0x3027980] Terminating filtering thread
 No more output streams to write to, finishing.0 size=N/A time=00:00:09.95
 bitrate=N/A speed=2.77x
 [vost#0:0/wrapped_avframe @ 0x3038200] Encoder thread received EOF
 [vost#0:0/wrapped_avframe @ 0x3038200] Encoder returned EOF, finishing
 [vost#0:0/wrapped_avframe @ 0x3038200] Terminating encoder thread
 [out#0/null @ 0x3029580] All streams finished
 [out#0/null @ 0x3029580] Terminating muxer thread
 [vost#1:0/wrapped_avframe @ 0x30397c0] Encoder thread received EOF
 [vost#1:0/wrapped_avframe @ 0x30397c0] Encoder returned EOF, finishing
 [vost#1:0/wrapped_avframe @ 0x30397c0] Terminating encoder thread
 [vost#2:0/wrapped_avframe @ 0x303b480] Encoder thread received EOF
 [vost#2:0/wrapped_avframe @ 0x303b480] Encoder returned EOF, finishing
 [vost#2:0/wrapped_avframe @ 0x303b480] Terminating encoder thread
 [out#1/null @ 0x30525c0] All streams finished
 [out#1/null @ 0x30525c0] Terminating muxer thread
 [out#2/null @ 0x303a580] All streams finished
 [out#2/null @ 0x303a580] Terminating muxer thread
 [vost#3:0/wrapped_avframe @ 0x303d2c0] Encoder thread received EOF
 [vost#3:0/wrapped_avframe @ 0x303d2c0] Encoder returned EOF, finishing
 [vost#3:0/wrapped_avframe @ 0x303d2c0] Terminating encoder thread
 [out#3/null @ 0x303c380] All streams finished
 [out#3/null @ 0x303c380] Terminating muxer thread
 [out#0/null @ 0x3029580] Output file #0 (pipe:):
 [out#0/null @ 0x3029580]   Output stream #0:0 (video): 240 frames encoded;
 240 packets muxed (115200 bytes);
 [out#0/null @ 0x3029580]   Total: 240 packets (115200 bytes) muxed
 [out#0/null @ 0x3029580] video:112kB audio:0kB subtitle:0kB other
 streams:0kB global headers:0kB muxing overhead: unknown
 [out#1/null @ 0x30525c0] Output file #1 (pipe:):
 [out#1/null @ 0x30525c0]   Output stream #1:0 (video): 240 frames encoded;
 240 packets muxed (115200 bytes);
 [out#1/null @ 0x30525c0]   Total: 240 packets (115200 bytes) muxed
 [out#1/null @ 0x30525c0] video:112kB audio:0kB subtitle:0kB other
 streams:0kB global headers:0kB muxing overhead: unknown
 [out#2/null @ 0x303a580] Output file #2 (pipe:):
 [out#2/null @ 0x303a580]   Output stream #2:0 (video): 240 frames encoded;
 240 packets muxed (115200 bytes);
 [out#2/null @ 0x303a580]   Total: 240 packets (115200 bytes) muxed
 [out#2/null @ 0x303a580] video:112kB audio:0kB subtitle:0kB other
 streams:0kB global headers:0kB muxing overhead: unknown
 [out#3/null @ 0x303c380] Output file #3 (pipe:):
 [out#3/null @ 0x303c380]   Output stream #3:0 (video): 1 frames encoded; 1
 packets muxed (480 bytes);
 [out#3/null @ 0x303c380]   Total: 1 packets (480 bytes) muxed
 [out#3/null @ 0x303c380] video:0kB audio:0kB subtitle:0kB other
 streams:0kB global headers:0kB muxing overhead: unknown
 frame=  240 fps= 67 q=-0.0 Lq=-0.0 q=-0.0 q=-0.0 size=N/A time=00:00:09.95
 bitrate=N/A speed=2.77x
 [Parsed_fps_6 @ 0x7f2d9c02c880] 240 frames in, 1 frames out; 239 frames
 dropped, 0 frames duplicated.
         Command being timed: "ffmpeg -v verbose -filter_complex
 testsrc2=r=24:d=10:s=1280x720,split=4[v0][v1][v2][thumb_in];[v0]scale=3840:2160[out0];[v1]scale=1920:1080[out1];[v2]scale=1280:720[out2];[thumb_in]fps=1/60:round=up:start_time=0[thumb_out]
 -map [out0] -f null pipe: -map [out1] -f null pipe: -map [out2] -f null
 pipe: -map [thumb_out] -f null pipe:"
         User time (seconds): 6.46
         System time (seconds): 3.02
         Percent of CPU this job got: 230%
         Elapsed (wall clock) time (h:mm:ss or m:ss): 0:04.11
         Average shared text size (kbytes): 0
         Average unshared data size (kbytes): 0
         Average stack size (kbytes): 0
         Average total size (kbytes): 0
         Maximum resident set size (kbytes): 3983600
         Average resident set size (kbytes): 0
         Major (requiring I/O) page faults: 0
         Minor (reclaiming a frame) page faults: 994229
         Voluntary context switches: 10705
         Involuntary context switches: 144
         Swaps: 0
         File system inputs: 0
         File system outputs: 0
         Socket messages sent: 0
         Socket messages received: 0
         Signals delivered: 0
         Page size (bytes): 4096
         Exit status: 0
 }}}

--
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10976#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list