This commit is contained in:
2025-10-31 11:10:02 +08:00
parent f00e01fd9e
commit e4ae201289
5 changed files with 5088 additions and 8 deletions

Binary file not shown.

View File

@@ -4,6 +4,8 @@
1.启动RTSP推流
2.启动系统各项服务,用于和双目交互
3.启动mqtt,与App进行数据交互
认证失败则会退出程序
*/
#include <iostream>
@@ -101,8 +103,8 @@ void getMsgCallback(mqtt::const_message_ptr msg);
int main(int argc, char *argv[])
{
// 开启4G模块
// StartNet();
// this_thread::sleep_for(chrono::seconds(2));
StartNet();
this_thread::sleep_for(chrono::seconds(2));
// 关闭全部信号
blockAllSignals();
@@ -115,8 +117,6 @@ int main(int argc, char *argv[])
return 0;
}
// 验证成功,启动程序
// 初始化mqtt
mqttInit();
@@ -280,7 +280,7 @@ void getMsgCallback(mqtt::const_message_ptr msg)
// 开启服务:fastApi,pub
void StartService()
{
string commnd = "echo 'orangepi' | sudo -S ../../StartService/bin/start start";
string commnd = "echo 'orangepi' | sudo -S -E env PATH=$PATH ../../StartService/bin/start start";
system(commnd.c_str());
}
@@ -376,7 +376,13 @@ void OpenRTSP()
void VideoStream()
{
// 静音ffmpeg的统计输出保留错误避免污染日志
string commnd = "ffmpeg -nostats -hide_banner -loglevel error -f v4l2 -i /dev/video0 -c:v h264_rkmpp -rtsp_transport tcp -f rtsp rtsp://192.168.12.1:8554/stream 2>/dev/null";
// string commnd = "ffmpeg -nostats -hide_banner -loglevel error -f v4l2 -i /dev/video0 -c:v h264_rkmpp -rtsp_transport tcp -f rtsp rtsp://192.168.12.1:8554/stream 2>/dev/null";
string commnd =
"VIDEO_SIZE=$(xdpyinfo | awk '/dimensions:/ {print $2}'); "
"DISPLAY_VAL=${DISPLAY:-:0.0}; "
"ffmpeg -nostats -hide_banner -loglevel error "
"-f x11grab -framerate 15 -video_size \"$VIDEO_SIZE\" -i \"$DISPLAY_VAL\" "
"-c:v h264_rkmpp -b:v 2000k -f rtsp rtsp://192.168.12.1:8554/stream 2>/dev/null";
video_proc = bp::child("/bin/bash", bp::args = {"-c", commnd});
}