[FFmpeg-user] How to drop frames to limit memory usage (or keep latency low)?
a.nielsen at shikadi.net
Wed Apr 4 06:55:38 EEST 2018
I am transcoding footage from a security camera from MJPEG into MPEG2,
but the machine I'm doing it on can't quite manage it in real-time.
It's pegged at 100% CPU usage but after 10 minutes it exhausts the
available memory and the output video becomes full of visual artefacts.
As far as I can tell, it's not a memory leak but rather the input
frames from the camera being buffered, because the transcoding is
happening slower than real-time. So I am looking for some way to
prevent this buffer from growing so large that it causes problems.
Since it's security camera footage, I don't mind if a few frames are
dropped here and there. If I could set a memory limit and have frames
dropped once this limit is reached, that would be good. Alternatively a
low latency/realtime option that dropped frames if the output was
getting too far behind the input would perhaps be even better.
I've had a look through the manpage but I can't find any options that
can do this. The -r and -vsync options seem to only drop frames to
match a constant framerate (rather than trying to minimise latency) and
-frame_drop_threshold looks to be similar, keeping up with timestamps
rather than affecting latency.
Is there some option that will effectively drop frames in order to
prevent the latency from becoming too great?
This is what I'm running now:
ffmpeg -overrun_nonfatal 1 -y -i udp://126.96.36.199
-c mpeg2video -b:v 2M -vf transpose=2
-preset ultrafast -an -r 30
More information about the ffmpeg-user