This commit is contained in:
2025-11-07 15:04:34 +08:00
parent efc6a92059
commit 09b6cab3cf
6 changed files with 122 additions and 11 deletions

View File

@@ -378,10 +378,11 @@ 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 =
"VIDEO_SIZE=$(xdpyinfo | awk '/dimensions:/ {print $2}'); "
"DISPLAY_VAL=${DISPLAY:-:0.0}; "
"export DISPLAY=${DISPLAY:-:0}; "
"VIDEO_SIZE=$(DISPLAY=$DISPLAY xdpyinfo 2>/dev/null | awk '/dimensions:/ {print $2}'); "
"if [ -z \"$VIDEO_SIZE\" ]; then VIDEO_SIZE=1920x1080; fi; "
"ffmpeg -nostats -hide_banner -loglevel error "
"-f x11grab -framerate 15 -video_size \"$VIDEO_SIZE\" -i \"$DISPLAY_VAL\" "
"-f x11grab -framerate 15 -video_size \"$VIDEO_SIZE\" -i \"$DISPLAY\" "
"-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});
}