[FFmpeg-user] Question regarding memory usage in combination with variable framerate inputs

Dominic ffmpeg at msrd0.de
Wed Jul 3 14:41:22 EEST 2024


Hi,

I regularly cut videos using ffmpeg, where I have two inputs: One
camera recording FHD at 50 and one screen recording recording some format
slightly smaller than FHD and with a variable frame rate, averaging to
something between 20 and 25 fps usually.

I then take a black FHD canvas at 50 fps, overlay the screen recording
on top, aligned to the left side, so there is a small black border on
the right. The camera should sometimes be fullscreen and sometimes be
in the top right corner, so I use a commands file that sends the
correct values for the scale filter, and overlay that on top of the
previous overlays.

My filter chain would look something like this:

[0]fps=50,sendcmd=f=camera.cmd,scale at cam[camera];

color=c=black:size=1920x1080,fps=50[background];
[1]fps=50,setpts=PTS+$screen_offset/TB[screen_tmp];
[background][screen_tmp]overlay=x=0:y=0:shortest=1[screen];

[screen][camera]overlay=x=W-w:y=0:repeatlast=0[video]

I even insert fps=50 commands everywhere to assure that ffmpeg doesn't
default to 25fps which has happened to me before.

Unfortunately, this command regularly gets killed by my kernel due to
excessive RAM usage. It usually happens a few minutes after the screen
recording starts.

When I preprocess the screen recording using -vf fps=50 filter, i.e.
transform it into a fixed frame rate video, before passing it to the
above filters, everything works as expected.

Am I doing something wrong? Is it possible to avoid re-encoding the
input before doing the actual encoding, without getting my kernel
upset?

Thanks,
Dominic


More information about the ffmpeg-user mailing list