From b2bbb2cbec0801e4f86f34904ed6fa4d8efa37e9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 19 Sep 2026 14:51:06 -0400 Subject: [PATCH] refactor: check camera dimensions against the stream, not the decoder The mismatch Debug compared the monitor's configured size against the decoder context's. Both hold the same numbers -- the context is filled from the stream's codecpar a few lines earlier -- but the stream is the thing actually describing what the camera sends, and reading it here means the check no longer needs a decoder to have been opened. That matters for the next step: this was the camera's last use of the decoder context for anything other than handing it out. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_015Y6FieTwEXuLhhR4e2yiax --- src/zm_ffmpeg_camera.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index bfa05f3bc..e5bc6c457 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -653,13 +653,17 @@ int FfmpegCamera::OpenFfmpeg() { } } // end if have audio stream + // Ask the stream, not the decoder. Both carry the same dimensions -- the + // decoder context is filled from the stream's codecpar -- but the stream is + // what the camera is actually sending, and reading it here means this check + // does not depend on a decoder having been opened. if ( - ((unsigned int)mVideoCodecContext->width != width) + ((unsigned int)mVideoStream->codecpar->width != width) || - ((unsigned int)mVideoCodecContext->height != height) + ((unsigned int)mVideoStream->codecpar->height != height) ) { Debug(1, "Monitor dimensions are %dx%d but camera is sending %dx%d", - width, height, mVideoCodecContext->width, mVideoCodecContext->height); + width, height, mVideoStream->codecpar->width, mVideoStream->codecpar->height); } // Seed fallback per-frame durations (in each stream's time_base) used to space