This commit is contained in:
cxh 2026-01-09 11:19:43 +08:00
parent b81980eb52
commit 57ab5fae7c

View File

@ -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";