This commit is contained in:
cxh 2026-01-09 10:14:16 +08:00
parent e3c2778530
commit d292a70a54

View File

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