增加码率自定义,config已更新

This commit is contained in:
cxh 2025-09-23 08:43:02 +08:00
parent e524858cef
commit d09f78a948
3 changed files with 17 additions and 13 deletions

View File

@ -14,7 +14,7 @@
"device": "/dev/video11",
"name": "AHD1",
"enabled": true,
"resolution": "720p",
"bitrate": 2000000,
"width": 1280,
"height": 720,
"fps": 30
@ -23,7 +23,7 @@
"device": "/dev/video12",
"name": "AHD2",
"enabled": false,
"resolution": "720p",
"bitrate": 2000000,
"width": 1280,
"height": 720,
"fps": 30
@ -32,7 +32,7 @@
"device": "/dev/video13",
"name": "AHD3",
"enabled": false,
"resolution": "720p",
"bitrate": 2000000,
"width": 1280,
"height": 720,
"fps": 30
@ -41,7 +41,7 @@
"device": "/dev/video14",
"name": "AHD4",
"enabled": false,
"resolution": "720p",
"bitrate": 2000000,
"width": 1280,
"height": 720,
"fps": 30
@ -50,7 +50,7 @@
"device": "/dev/video3",
"name": "AHD5",
"enabled": false,
"resolution": "1080p",
"bitrate": 2000000,
"width": 1920,
"height": 1080,
"fps": 30
@ -59,7 +59,7 @@
"device": "/dev/video2",
"name": "AHD6",
"enabled": false,
"resolution": "1080p",
"bitrate": 2000000,
"width": 1920,
"height": 1080,
"fps": 30
@ -68,7 +68,7 @@
"device": "/dev/video1",
"name": "AHD7",
"enabled": false,
"resolution": "1080p",
"bitrate": 2000000,
"width": 1920,
"height": 1080,
"fps": 30
@ -77,7 +77,7 @@
"device": "/dev/video0",
"name": "AHD8",
"enabled": false,
"resolution": "1080p",
"bitrate": 2000000,
"width": 1920,
"height": 1080,
"fps": 30

View File

@ -20,6 +20,7 @@ struct Camera
std::string device;
std::string name;
int width, height, fps;
int bitrate; // 新增码率字段 (bps)
bool enabled;
};
@ -95,10 +96,12 @@ struct AppConfig
cam.width = c.value("width", 1280);
cam.height = c.value("height", 720);
cam.fps = c.value("fps", 30);
cam.bitrate = c.value("bitrate", 2000000);
cam.enabled = c.value("enabled", false);
cfg.cameras.push_back(cam);
LOG_INFO("[Config] Loaded camera: " + cam.name +
" (" + cam.device + "), enabled=" + std::to_string(cam.enabled));
" (" + cam.device + "), enabled=" + std::to_string(cam.enabled) +
", bitrate=" + std::to_string(cam.bitrate));
}
}

View File

@ -36,8 +36,9 @@ GstRTSPMediaFactory *RTSPManager::create_media_factory(const Camera &cam)
",height=" + std::to_string(out_height) +
",framerate=" + std::to_string(cam.fps) + "/1"
" ! queue max-size-buffers=1 leaky=downstream" // 最小队列
" ! mpph264enc bps=2000000 gop=" +
std::to_string(cam.fps) + " " // 固定 4Mbps
" ! mpph264enc bps=" +
std::to_string(cam.bitrate) +
" gop=" + std::to_string(cam.fps) + // GOP 设置为 1 秒
" ! h264parse"
" ! rtph264pay name=pay0 pt=96 config-interval=1 )"; // 每秒发送 SPS/PPS