From d292a70a544462d7f4f3c89cc0a6a05104f55501 Mon Sep 17 00:00:00 2001 From: cxh Date: Fri, 9 Jan 2026 10:14:16 +0800 Subject: [PATCH] 1 --- src/rtmp_manager.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/rtmp_manager.cpp b/src/rtmp_manager.cpp index 4cccdd3..7894b58 100644 --- a/src/rtmp_manager.cpp +++ b/src/rtmp_manager.cpp @@ -59,26 +59,23 @@ GstElement* RTMPManager::create_pipeline(const Camera& cam) std::string pipeline_str = "v4l2src device=" + cam.device + " io-mode=dmabuf " - // 原始输入 "! video/x-raw,format=NV12,width=1280,height=960,framerate=30/1 " - // 裁剪 + 缩放 "! videocrop top=120 bottom=120 " + "! videoscale " - // ⭐ 关键:在 RAW 阶段强制重打时钟(修复“看着一顿”) + // ⭐ 关键:重建时间轴 "! videorate " "! video/x-raw,framerate=30/1 " - // 输出分辨率 + // ⭐ 输出尺寸(注意这里前后都有空格) "! 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 " - // 编码 "! mpph264enc rc-mode=cbr " "bps=" + std::to_string(cam.bitrate) + @@ -88,14 +85,15 @@ GstElement* RTMPManager::create_pipeline(const Camera& cam) " " "header-mode=each-idr profile=main " - // H264 处理 - "! h264parse name=parse config-interval=1 " + "! h264parse config-interval=1 " "! video/x-h264,stream-format=avc,alignment=au " - // RTMP "! flvmux streamable=true " + "! rtmpsink location=\"" + - rtmp_url + "\" sync=false async=false"; + rtmp_url + + "\" " + "sync=false async=false"; GError* error = nullptr; GstElement* pipeline = gst_parse_launch(pipeline_str.c_str(), &error);