From 3832cee181e8ef9dc0b91e2e7290fcf557ac32dc Mon Sep 17 00:00:00 2001 From: cxh Date: Mon, 29 Dec 2025 14:29:41 +0800 Subject: [PATCH] 1 --- src/rtmp_manager.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/rtmp_manager.cpp b/src/rtmp_manager.cpp index 12f4ebf..d10c3ba 100644 --- a/src/rtmp_manager.cpp +++ b/src/rtmp_manager.cpp @@ -68,29 +68,35 @@ GstElement* RTMPManager::create_pipeline(const Camera& cam) const std::string live_rtmp = "rtmp://36.153.162.171:19435/" + app + "/" + stream + "?vhost=live"; - std::string pipeline_str = "v4l2src name=src device=" + cam.device + + std::string pipeline_str = "v4l2src device=" + cam.device + " io-mode=dmabuf " "! video/x-raw,format=NV12," "width=" + - std::to_string(cam.width) + ",height=" + std::to_string(cam.height) + - ",framerate=" + std::to_string(cam.fps) + + std::to_string(width) + ",height=" + std::to_string(height) + + ",framerate=" + std::to_string(fps) + "/1 " - "! queue max-size-buffers=4 max-size-time=0 leaky=downstream " + + "! queue max-size-buffers=4 leaky=downstream " + "! mpph264enc " + "rc-mode=cbr " "bps=" + - std::to_string(cam.bitrate) + + std::to_string(bitrate) + " " "gop=" + - std::to_string(cam.fps) + + std::to_string(fps) + " " - "rc-mode=cbr " "header-mode=each-idr " + "! h264parse config-interval=1 " + + // ⭐ 核心修复:统一 DTS / PTS + "! identity sync=true single-segment=true " + "! flvmux streamable=true " + "! rtmpsink location=\"" + - live_rtmp + - "\" " - "sync=false async=false"; + live_rtmp + "\" sync=false async=false"; GError* error = nullptr; GstElement* pipeline = gst_parse_launch(pipeline_str.c_str(), &error);