This commit is contained in:
cxh 2026-01-09 10:10:52 +08:00
parent b6fd603408
commit e3c2778530

View File

@ -59,15 +59,26 @@ 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) +
@ -77,9 +88,11 @@ GstElement* RTMPManager::create_pipeline(const Camera& cam)
" "
"header-mode=each-idr profile=main "
// H264 处理
"! h264parse name=parse config-interval=1 "
"! video/x-h264,stream-format=avc,alignment=au "
// RTMP
"! flvmux streamable=true "
"! rtmpsink location=\"" +
rtmp_url + "\" sync=false async=false";