From 57ab5fae7cf83a294505daa3311b7ee7961848e5 Mon Sep 17 00:00:00 2001 From: cxh Date: Fri, 9 Jan 2026 11:19:43 +0800 Subject: [PATCH] 1 --- src/rtmp_manager.cpp | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/rtmp_manager.cpp b/src/rtmp_manager.cpp index 71a6702..8c9bc01 100644 --- a/src/rtmp_manager.cpp +++ b/src/rtmp_manager.cpp @@ -54,36 +54,32 @@ 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 " + std::string pipeline_str = "v4l2src name=src device=" + cam.device + + " io-mode=dmabuf " "! video/x-raw,format=NV12,width=1280,height=960,framerate=30/1 " - - // ⭐ 吸震:小队列 + upstream 泄漏(丢旧帧,保实时) - "! queue max-size-buffers=4 max-size-time=0 leaky=upstream " - - // 你原来的裁剪缩放可以保留 + "! videoscale method=nearest-neighbour " "! 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=8 max-size-time=0 leaky=downstream " - + ",pixel-aspect-ratio=1/1 " + "! queue max-size-buffers=6 max-size-time=0 max-size-bytes=0 " "! mpph264enc rc-mode=cbr " "bps=" + - std::to_string(cam.bitrate) + + std::to_string(bitrate) + " " - "gop=30 header-mode=each-idr profile=main " - - "! h264parse name=parse config-interval=1 " + "max-bps=" + + std::to_string(bitrate) + + " " + "min-bps=" + + std::to_string(bitrate) + + " " + "gop=" + + std::to_string(fps) + + " " + "header-mode=each-idr profile=main " + "! h264parse config-interval=1 " "! video/x-h264,stream-format=avc,alignment=au " "! flvmux streamable=true " - - // rtmpsink 不要 sync,避免等时钟 "! rtmpsink location=\"" + rtmp_url + "\" sync=false async=false";