diff --git a/config.json b/config.json new file mode 100644 index 0000000..f07f121 --- /dev/null +++ b/config.json @@ -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 + } + ] +} diff --git a/rtsp_release_250910.tar.gz b/rtsp_release_250910.tar.gz deleted file mode 100644 index b9d530d..0000000 Binary files a/rtsp_release_250910.tar.gz and /dev/null differ diff --git a/src/rtsp_manager.cpp b/src/rtsp_manager.cpp index 488d83f..88ab873 100644 --- a/src/rtsp_manager.cpp +++ b/src/rtsp_manager.cpp @@ -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());