mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-07-29 06:16:52 -04:00
perf: default ffmpeg decoder thread_count to 2
libavcodec's avcodec_alloc_context3 leaves thread_count at 1, so software 1080p H.264 decoding hits ~60ms/frame and saturates a core per camera. Default to 2 frame-threads, which roughly halves per- frame decode time without oversubscribing systems with many cameras. User can still override via thread_count in monitor Options (0 = let ffmpeg auto-detect based on CPU count). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -422,6 +422,13 @@ int FfmpegCamera::OpenFfmpeg() {
|
||||
mVideoCodecContext->framerate = mVideoStream->r_frame_rate;
|
||||
mVideoCodecContext->sw_pix_fmt = chosen_codec_data->sw_pix_fmt;
|
||||
|
||||
// libavcodec defaults thread_count to 1, making software 1080p H.264
|
||||
// decode hit ~60ms/frame and saturate a core per camera. Default to 2
|
||||
// frame-threads instead. User can override (including 0 = auto) via
|
||||
// thread_count in monitor Options.
|
||||
mVideoCodecContext->thread_count = 2;
|
||||
mVideoCodecContext->thread_type = FF_THREAD_FRAME | FF_THREAD_SLICE;
|
||||
|
||||
// Set default options for this codec
|
||||
if (chosen_codec_data->options_defaults) {
|
||||
AVDictionary *opts_defaults = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user