This commit is contained in:
cxh 2026-01-09 11:21:13 +08:00
parent 57ab5fae7c
commit 9802543284

View File

@ -52,11 +52,16 @@ std::string RTMPManager::make_key(const std::string& name) { return name + "_mai
// ========== 创建 RTMP Pipeline ==========
GstElement* RTMPManager::create_pipeline(const Camera& cam)
{
const std::string rtmp_url = "rtmp://127.0.0.1:1935/" + cam.name;
const int fps = cam.fps > 0 ? cam.fps : 30;
const int bitrate = cam.bitrate > 0 ? cam.bitrate : 3500000;
const std::string rtmp_url = "rtmp://127.0.0.1:1935/live/" + cam.name;
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 "
"! video/x-raw,format=NV12,width=1280,height=960,framerate=" +
std::to_string(fps) +
"/1 "
"! videoscale method=nearest-neighbour "
"! videocrop top=120 bottom=120 "
"! video/x-raw,width=" +
@ -77,7 +82,7 @@ GstElement* RTMPManager::create_pipeline(const Camera& cam)
std::to_string(fps) +
" "
"header-mode=each-idr profile=main "
"! h264parse config-interval=1 "
"! h264parse name=parse config-interval=1 "
"! video/x-h264,stream-format=avc,alignment=au "
"! flvmux streamable=true "
"! rtmpsink location=\"" +