From 5ee6245d1bee272144d833ccab92d5665c226ece Mon Sep 17 00:00:00 2001 From: cxh Date: Fri, 17 Oct 2025 16:03:26 +0800 Subject: [PATCH] 1 --- src/rtmp_manager.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/rtmp_manager.cpp b/src/rtmp_manager.cpp index d1916bc..d4dba91 100644 --- a/src/rtmp_manager.cpp +++ b/src/rtmp_manager.cpp @@ -150,13 +150,25 @@ void RTMPManager::stream_loop(Camera cam, StreamContext *ctx) // 检查帧超时:3 秒内没有检测到帧 auto elapsed = std::chrono::duration_cast(std::chrono::steady_clock::now() - start_time).count(); - if (!got_frame && elapsed > 3) + if (!got_frame && elapsed > 5) { - ctx->status.running = false; - ctx->status.last_error = "No frames detected (no video signal)"; - LOG_ERROR("[RTMP] " + key + " - " + ctx->status.last_error); - need_restart = true; - break; + GstState state; + gst_element_get_state(pipeline, &state, nullptr, 0); + if (state != GST_STATE_PLAYING) + { + ctx->status.running = false; + ctx->status.last_error = "Pipeline failed to reach PLAYING (maybe no device signal)"; + LOG_ERROR("[RTMP] " + key + " - " + ctx->status.last_error); + need_restart = true; + break; + } + else + { + ctx->status.running = true; + ctx->status.last_error.clear(); + LOG_INFO("[RTMP] " + key + " reached PLAYING but no frames yet, assuming OK"); + got_frame = true; + } } if (!msg) continue;