新pipe和配置文件

This commit is contained in:
cxh 2025-11-05 16:59:04 +08:00
parent 408f248071
commit d76b6b42ed
3 changed files with 104 additions and 5 deletions

86
config.json Normal file
View File

@ -0,0 +1,86 @@
{
"mqtt_server": {
"veh_id": 20004,
"address": "192.168.3.19",
"port": 1883,
"need_username_pwd": true,
"client_id": "20004_vehmedia",
"username": "20004_82:AE:83:80:C4:DC",
"password": "b01fdfea00b10500c1bcb02d6286bb360433cfb47965ff803e2aea2629fc0a6e3c9baeb4c84558e2835625718d1e76c4191ad65f0e7c0d5562548d8a87bd8c140d52031e6b6763deb1b98d348f034465b0361bd0348ef6f2745ca3f7e7bbbf7a3b9a2cecf3c8b2453c5373ccbaf2f299ad24716c07cec60cec9d46dc610c6eaae05a53a7",
"mqtt_heart_threshold": 2000
},
"cameras": [
{
"device": "/dev/video0",
"name": "AHD1",
"enabled": true,
"bitrate": 200000,
"width": 1280,
"height": 960,
"fps": 30
},
{
"device": "/dev/video1",
"name": "AHD2",
"enabled": true,
"bitrate": 200000,
"width": 1280,
"height": 960,
"fps": 30
},
{
"device": "/dev/video2",
"name": "AHD3",
"enabled": true,
"bitrate": 200000,
"width": 1280,
"height": 960,
"fps": 30
},
{
"device": "/dev/video3",
"name": "AHD4",
"enabled": true,
"bitrate": 200000,
"width": 1280,
"height": 960,
"fps": 30
},
{
"device": "/dev/video11",
"name": "AHD5",
"enabled": false,
"bitrate": 1000000,
"width": 1920,
"height": 960,
"fps": 30
},
{
"device": "/dev/video12",
"name": "AHD6",
"enabled": false,
"bitrate": 1000000,
"width": 1920,
"height": 960,
"fps": 30
},
{
"device": "/dev/video13",
"name": "AHD7",
"enabled": false,
"bitrate": 1000000,
"width": 1920,
"height": 960,
"fps": 30
},
{
"device": "/dev/video14",
"name": "AHD8",
"enabled": false,
"bitrate": 1000000,
"width": 1920,
"height": 960,
"fps": 30
}
]
}

Binary file not shown.

View File

@ -30,17 +30,30 @@ GstRTSPMediaFactory *RTSPManager::create_media_factory(const Camera &cam)
int out_height = cam.height;
// 构建 pipeline
// std::string launch_str =
// "( v4l2src device=" + cam.device +
// " ! video/x-raw,format=NV12,width=" + std::to_string(out_width) +
// ",height=" + std::to_string(out_height) +
// ",framerate=" + std::to_string(cam.fps) + "/1"
// " ! queue max-size-buffers=1 leaky=downstream" // 最小队列
// " ! 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
std::string launch_str =
"( v4l2src device=" + cam.device +
" ! video/x-raw,format=NV12,width=" + std::to_string(out_width) +
",height=" + std::to_string(out_height) +
",framerate=" + std::to_string(cam.fps) + "/1"
" ! queue max-size-buffers=1 leaky=downstream" // 最小队列
" ! mpph264enc bps=" +
" ! queue max-size-buffers=1 leaky=downstream"
" ! mpph265enc rc-mode=cbr 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
" gop=" + std::to_string(cam.fps) +
" b-frames=0"
" ! h265parse config-interval=1"
" ! rtph265pay name=pay0 pt=96 config-interval=1 )";
GstRTSPMediaFactory *factory = gst_rtsp_media_factory_new();
gst_rtsp_media_factory_set_launch(factory, launch_str.c_str());