This commit is contained in:
cxh 2025-12-29 15:09:37 +08:00
parent 9a7de740f8
commit 3c982a311e

View File

@ -71,16 +71,24 @@ GstElement* RTMPManager::create_pipeline(const Camera& cam)
std::string pipeline_str = "v4l2src name=src device=" + cam.device + std::string pipeline_str = "v4l2src name=src device=" + cam.device +
" io-mode=dmabuf " " io-mode=dmabuf "
// ⭐ 相机真实输出:写死 1080p
"! video/x-raw,format=NV12," "! video/x-raw,format=NV12,"
"width=" + "width=1920,height=1080,"
std::to_string(cam.width) + ",height=" + std::to_string(cam.height) + "framerate=" +
",framerate=" + std::to_string(cam.fps) + std::to_string(cam.fps) +
"/1 " "/1 "
// 🔻 队列深度压到 2 帧(≈ 60ms@30fps // ⭐ 关键:在编码前缩放到“推流分辨率”
"! videoscale "
"! video/x-raw,"
"width=" +
std::to_string(cam.width) + ",height=" + std::to_string(cam.height) +
" "
// 🔻 低延时队列
"! queue max-size-buffers=2 max-size-time=0 leaky=downstream " "! queue max-size-buffers=2 max-size-time=0 leaky=downstream "
// 🔻 编码器baseline + CBR + 无 B 帧 // 🔻 编码器:SIM 卡友好
"! mpph264enc " "! mpph264enc "
"rc-mode=cbr " "rc-mode=cbr "
"bps=" + "bps=" +
@ -92,16 +100,9 @@ GstElement* RTMPManager::create_pipeline(const Camera& cam)
"header-mode=each-idr " "header-mode=each-idr "
"profile=baseline " "profile=baseline "
// SPS/PPS 每秒刷新一次SRS/WebRTC 友好)
"! h264parse config-interval=1 " "! h264parse config-interval=1 "
// 🔻 时间戳整形但不强行等待
"! identity sync=false single-segment=true " "! identity sync=false single-segment=true "
// FLV 最小缓存模式
"! flvmux streamable=true " "! flvmux streamable=true "
// sink 本身不参与同步
"! rtmpsink location=\"" + "! rtmpsink location=\"" +
live_rtmp + live_rtmp +
"\" " "\" "