Ffmpeg eats all the memory and crash within a minute - recording or streaming

I recommend people here to read my comment on github:

TL;DR, it seems like your ffmpeg is not capable to stream at 1x, and then keep the delay in memory until crashing.

That’s not the solution though. This is a hardware issue. If your CPU (also depends on the type) can’t handle the load, ffmpeg starts eating into your memory till it crashes.

I think that I’m saying the same, but well…
I just said that either your cpu can manage to encode at a 1x speed, and then you don’t have problems, or it is not able to follow the real time, your encoding speed is less than 1, and delay accumulate in your memory until there is no more memory and it crashes.