Opened 3 years ago

Closed 3 years ago

#8956 closed defect (invalid)

af1761f causes OOM

Reported by: llogan Owned by:
Priority: important Component: undetermined
Version: git-master Keywords: regression
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Regression since af1761f7b5b1b72197dc40934953b775c2d951cc can cause OOM and crash.

Two examples. In both I manually stopped the encoding before all 16 GB RAM consumed and computer freezes.

$ ./ffmpeg -f lavfi -i testsrc=s=1280x720 -filter_complex "[0][0]concat=n=2:v=1:a=0" -f null -
ffmpeg version N-99792-g37d742b607 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.2.0 (GCC)
  configuration: 
  libavutil      56. 60.100 / 56. 60.100
  libavcodec     58.112.100 / 58.112.100
  libavformat    58. 64.100 / 58. 64.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 88.100 /  7. 88.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
Input #0, lavfi, from 'testsrc=s=1280x720':
  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], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (rawvideo) -> concat:in0:v0
  Stream #0:0 (rawvideo) -> concat:in1:v0
  concat -> Stream #0:0 (wrapped_avframe)
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf58.64.100
    Stream #0:0: Video: wrapped_avframe, rgb24, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc58.112.100 wrapped_avframe
[out_0_0 @ 0x5620a99660c0] 100 buffers queued in out_0_0, something may be wrong.
[out_0_0 @ 0x5620a99660c0] 1000 buffers queued in out_0_0, something may be wrong.
frame= 5101 fps=303 q=-0.0 Lsize=N/A time=00:03:24.04 bitrate=N/A speed=12.1x    
video:2670kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

In the above example the memory consumption is avoided by using two of the same inputs instead of referring to the same input twice in the filtergraph.

$ ./ffmpeg -f lavfi -i testsrc=s=1280x720 -f lavfi -i testsrc=s=1280x720 -filter_complex "[0:v]nullsink;[1:v]nullsink" -map 0 -f null -
ffmpeg version N-99792-g37d742b607 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.2.0 (GCC)
  configuration: 
  libavutil      56. 60.100 / 56. 60.100
  libavcodec     58.112.100 / 58.112.100
  libavformat    58. 64.100 / 58. 64.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 88.100 /  7. 88.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
Input #0, lavfi, from 'testsrc=s=1280x720':
  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], 25 tbr, 25 tbn, 25 tbc
Input #1, lavfi, from 'testsrc=s=1280x720':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #1:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (rawvideo) -> nullsink (graph 0)
  Stream #1:0 (rawvideo) -> nullsink (graph 0)
  Stream #0:0 -> #0:0 (rawvideo (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf58.64.100
    Stream #0:0: Video: wrapped_avframe, rgb24, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.112.100 wrapped_avframe
frame= 4580 fps=299 q=-0.0 Lsize=N/A time=00:03:03.20 bitrate=N/A speed=  12x    
video:2397kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Not sure if it is a duplicate of other af1761f related tickets: #6323, #6472, #6375.

Change History (3)

in reply to:  description comment:1 by Cigaes, 3 years ago

Replying to llogan:

$ ./ffmpeg -f lavfi -i testsrc=s=1280x720 -filter_complex "[0][0]concat=n=2:v=1:a=0" -f null -


There is no way concatenating an infinite stream with itself can work with a finite amount of memory.


$ ./ffmpeg -f lavfi -i testsrc=s=1280x720 -f lavfi -i testsrc=s=1280x720 -filter_complex "[0:v]nullsink;[1:v]nullsink" -map 0 -f null -


ffmpeg is not designed for filter graphs without outputs.

comment:2 by llogan, 3 years ago

Perhaps the examples are poor, but the OOM issue in command #1 can be duplicated with a normal, finite input.

comment:3 by Elon Musk, 3 years ago

Resolution: invalid
Status: newclosed

concat can not work with exactly same inputs. This will always cause excessive buffering.

Note: See TracTickets for help on using tickets.