[FFmpeg-user] How to drop frames to limit memory usage (or keep latency low)?
Adam Nielsen
a.nielsen at shikadi.net
Thu Apr 5 05:17:21 EEST 2018
Hi Victor,
Many thanks for your reply!
> What you could do is reduce the output framerate by using the `-r
> (framerate)` or the `fps` video filter, which will reduce the
> encoding load on the CPU.
This looks like the best option for me. With fps=15, removing the
rotation filter, and adding your -tune stillimage suggestion, I can get
15fps transcoding at 1.05x realtime. I imagine this will slow down and
start using more memory for buffering if there's a lot of movement in
the image, but being slightly faster than realtime means it should
catch up again once the movement settles down.
> Also, I'm sure `mpeg2video` does not support encoding presets. If you
> want fast encoding, you may want to try `libx264` with `-preset
> ultrafast`, `-tune stillimage` and `-deblock 0:0`, since that can be
> faster than MPEG-2 depending on your CPU architecture, and maybe more
> efficient.
I tried this however it makes no difference to the encoding speed on
the Intel NUC platform I'm using (Intel i3 @ 2.1GHz). I did end up
switching to libx264 now that I realise it's no slower, as this matches
the format of the other files I'm getting from my other cameras,
however there was unfortunately no speed increase just from changing
the codec. The stillimage tuning option did provide a noticeable speed
boost though.
> If available on your platform, you may also want to try
> hardware-accelerated H 264 encoding APIs. You can find some info
> here: https://trac.ffmpeg.org/wiki/HWAccelIntro (note: you may have
> to compile a custom build of FFmpeg to enable this feature, as
> pre-built ones aren't usually compiled for it.
I have thought about this as the video is coming from a Raspberry Pi,
which apparently has hardware H264 encoding now. I am not sure if it
has enough power to encode two H264 streams at the same time (both the
Pi camera and the MJPEG USB camera that is the root cause of this issue)
but if it can, that will probably be the best option.
Thanks again for your help!
Cheers,
Adam.
More information about the ffmpeg-user
mailing list