diff --git a/src/rtmp_manager.cpp b/src/rtmp_manager.cpp index c060c5f..71a6702 100644 --- a/src/rtmp_manager.cpp +++ b/src/rtmp_manager.cpp @@ -54,38 +54,38 @@ GstElement* RTMPManager::create_pipeline(const Camera& cam) { const std::string rtmp_url = "rtmp://127.0.0.1:1935/" + cam.name; + // 关键:v4l2src 后立刻加“吸震队列”,避免回压把采集端憋死 + // 关键:h264parse 起名,给你后续要 probe 也能准确找到(但现在先别 probe) std::string pipeline_str = "v4l2src device=" + cam.device + - " io-mode=dmabuf " - "do-timestamp=true " // ⭐⭐ 正确位置:就在 v4l2src 上 - + " io-mode=dmabuf do-timestamp=true " "! video/x-raw,format=NV12,width=1280,height=960,framerate=30/1 " - "! videocrop top=120 bottom=120 " + // ⭐ 吸震:小队列 + upstream 泄漏(丢旧帧,保实时) + "! queue max-size-buffers=4 max-size-time=0 leaky=upstream " + // 你原来的裁剪缩放可以保留 + "! videocrop top=120 bottom=120 " "! videoscale " "! video/x-raw,width=" + std::to_string(cam.width) + ",height=" + std::to_string(cam.height) + " " - "! queue max-size-buffers=12 max-size-time=0 leaky=downstream " + // 再来一个队列隔离编码器 + "! queue max-size-buffers=8 max-size-time=0 leaky=downstream " "! mpph264enc rc-mode=cbr " "bps=" + std::to_string(cam.bitrate) + " " - "gop=30 " - "header-mode=each-idr " - "profile=main " + "gop=30 header-mode=each-idr profile=main " "! h264parse name=parse config-interval=1 " "! video/x-h264,stream-format=avc,alignment=au " - "! flvmux streamable=true " + // rtmpsink 不要 sync,避免等时钟 "! rtmpsink location=\"" + - rtmp_url + - "\" " - "sync=false async=false"; + rtmp_url + "\" sync=false async=false"; LOG_INFO("[PIPELINE] " + pipeline_str); @@ -97,7 +97,6 @@ GstElement* RTMPManager::create_pipeline(const Camera& cam) g_error_free(error); return nullptr; } - return pipeline; }