一、前言说明
在银行、超市、考试中心、工控系统、网课教学、居家办公等场景中,传统监控摄像头难以清晰录制电脑屏幕内容,导致关键操作无法有效追溯。为解决这一难题,我们推出了一套纯软件实现的电子屏幕监控方案,彻底取代依赖硬件视频编码器的传统方式,实现高效、清晰、低成本的电脑屏幕录像监控。
本方案基于虚拟摄像头技术,将安装了该软件的电脑模拟为标准ONVIF网络摄像机。通过ONVIF或RTSP协议,监控录像机、NVR、VMS系统或各类监控软件可直接发现并接入该“虚拟摄像头”,实时录制电脑屏幕画面、本地摄像头视频、麦克风音频,甚至指定视频文件的播放内容。纯软件实现电脑屏幕监控:绿色版ONVIF虚拟摄像头,助力安全审计与操作留痕。通过本方案,企业可构建一套完整的电脑行为监控与录像追溯体系,提升信息安全等级,满足合规审计要求,真正实现“看得见、录得清、查得到”的数字化监管目标。
✅ 核心优势:
- 绿色免安装,双击即用:无需复杂配置,不修改系统关键组件,安全可靠。
- 无缝集成现有监控系统:自动被主流录像机和监控平台识别为ONVIF设备,轻松纳入统一管理。
- 全操作留痕:所有屏幕活动、应用程序使用、文件操作均可被录像保存,支持随时回放与审计。
- 多场景适用:适用于现金终端、汽车检测、工控操作、在线考试、计算机安全审计等需操作追溯的场景。
- 强化数据安全:有效防范恶意篡改、越权操作或意外事故导致的数据丢失,实现“操作有迹可循”。
二、效果图
三、相关地址
- 国内站点:https://gitee.com/feiyangqingyun
- 国际站点:https://github.com/feiyangqingyun
- 个人作品:https://blog.csdn.net/feiyangqingyun/article/details/97565652
- 文件地址:https://pan.baidu.com/s/1d7TH_GEYl5nOecuNlWJJ7g 提取码:01jf 文件名:bin_video_simulate。
四、功能特点
- 标准onvif协议,支持设备搜索、获取参数、快照抓图等。
- 支持264/265/aac等标准视音频协议传输。
- 支持多路批量onvif设备模拟,每一路都独立的端口。
- 支持本地摄像头采集转成onvif,可选择不同的设备、分辨率、帧率等参数。
- 支持本地桌面采集转成onvif,可选择不同的屏幕、分辨率、帧率等参数。
- 支持各种视频文件和视频流转成onvif,可重新设置编码转换以及分辨率转换。
- 支持4K、8K等高清分辨率,不限制分辨率,非264/265会自动转码推流。
- 每一路都可以设置统一或者独立的用户验证信息,为空则表示不验证。
- 可以把任意内容接入到NVR以及视频监控系统,方便保存录像文件,以便回放可查。
- 也可作为压力测试工具,比如模拟几千路onvif设备,让集成平台软件做接入压力测试。
- 推出去的流不仅有rtsp格式,还支持rtmp、http、flv、ws-flv、webrtc等方式访问,可以直接网页查看。
- 在管理工具上可以看到每一路的推流状况以及分辨率信息,非常直观。
- 支持自动重连拉流,重连推流,保证7乘以24小时稳定运行。
- 可设置开机自启动运行和后台运行,不显示在任务栏,作为后台服务运行。
- 可批量添加文件、添加目录,自动将目录下的所有文件添加到模拟器。
- 多功能添加地址面板,可以选择本地设备和监控设备,本地设备会自动识别摄像头设备和桌面设备,监控设备可以选择不同厂家,自动填充对应rtsp格式,填入用户信息即可,可以批量递增添加监控设备。
- 可无缝上传到市面上所有的onvif协议设备,包括海康、大华、宇视、华为、天地伟业等,也支持ONVIF Device Manager国际onvif工具。
- 支持gb28181设备模拟,具备设备注册、设备注销、设备心跳、设备信息、设备配置、设备状态应答等。
- 支持模拟报警和位置上报等,方便平台侧显示对应设备的实时位置。
- 支持一键添加批量模拟28181设备,实时显示已注册和已注销状态。
- 支持将本地桌面、本地摄像头、任意视频文件、视频流文件、手机摄像头等转换成28181设备,添加到NVR或者国标软件平台。
- sip协议同时支持udp和tcp两种通信方式,视频点播同时支持udp/tcp主动/tcp被动三种方式,涵盖所有可能的场景需求。
- 无论是onvif设备模拟组件还是28181设备模拟组件,全部原创底层协议解析,纯Qt实现,跨任意平台。
- 代码结构框架非常清晰,注释详细,代码精简不繁琐,非常易于学习和移植,可以很容易拓展其他接口需求。
- 支持Qt4/Qt5/Qt6以及后续所有版本、所有编译器、所有开发环境。
- 支持windows、linux、mac、国产OS、嵌入式linux、RK3588、树莓派、香橙派等系统。
五、相关代码
#include "onvifdeviceserver.h"
#include "onvifdevicesearch.h"
#include "onvifdevicepush.h"
#include "onvifdevicelisten.h"
#include "onvifdevicehelper.h"OnvifDeviceServer::OnvifDeviceServer(QObject *parent) : QObject(parent)
{serverHost = "127.0.0.1";serverIp = "127.0.0.1";userName = "admin";userPwd = "123456";//实例化onvif搜索类并关联信号槽isStart = false;onvifSearch = new OnvifDeviceSearch(this);connect(onvifSearch, SIGNAL(sendData(QByteArray)), this, SIGNAL(sendData(QByteArray)));connect(onvifSearch, SIGNAL(receiveData(QByteArray)), this, SIGNAL(receiveData(QByteArray)));connect(onvifSearch, SIGNAL(receiveInfo(QString)), this, SIGNAL(receiveInfo(QString)));connect(onvifSearch, SIGNAL(receiveError(QString)), this, SIGNAL(receiveError(QString)));
}OnvifDeviceServer::~OnvifDeviceServer()
{this->stop();
}void OnvifDeviceServer::setPara(const QString &serverHost, const QString &serverIp, const QString &userName, const QString &userPwd)
{this->serverHost = serverHost;this->serverIp = serverIp;this->userName = userName;this->userPwd = userPwd;
}bool OnvifDeviceServer::start()
{foreach (OnvifDevicePush *push, listPush) {if (!push->isOk()) {push->start();}}foreach (OnvifDeviceListen *listen, listListen) {if (!listen->isOk()) {listen->start();}}isStart = true;return onvifSearch->start(serverIp);
}void OnvifDeviceServer::stop()
{foreach (OnvifDevicePush *push, listPush) {push->stop();}foreach (OnvifDeviceListen *listen, listListen) {listen->stop();}isStart = false;onvifSearch->stop();
}bool OnvifDeviceServer::append(const QString &flag, int port, const QString &mediaUrl, const QString &rtspUrl)
{//构建onvif地址/已经存在说明冲突了QString hard = OnvifDeviceHelper::getUuid();QString addr = QString("http://%1:%2/onvif").arg(serverHost).arg(port);if (listFlag.contains(flag)) {QMessageBox::critical(0, "错误", "推流码重复, 请重新填写!");return false;} else if (listAddr.contains(addr)) {QMessageBox::critical(0, "错误", "端口号重复, 请重新填写!");return false;}//启动推流服务OnvifDevicePush *push = new OnvifDevicePush;connect(push, SIGNAL(pushStart(QString, int, int, bool)), this, SLOT(slot_pushStart(QString, int, int, bool)));connect(push, SIGNAL(pushChanged(QString, int)), this, SIGNAL(pushChanged(QString, int)));connect(push, SIGNAL(pushImage(QString, QImage)), this, SIGNAL(pushImage(QString, QImage)));push->setPara(flag, mediaUrl, rtspUrl);//启动监听服务OnvifDeviceListen *listen = new OnvifDeviceListen;connect(listen, SIGNAL(sendData(QByteArray)), this, SIGNAL(sendData(QByteArray)));connect(listen, SIGNAL(receiveData(QByteArray)), this, SIGNAL(receiveData(QByteArray)));connect(listen, SIGNAL(receiveInfo(QString)), this, SIGNAL(receiveInfo(QString)));connect(listen, SIGNAL(receiveError(QString)), this, SIGNAL(receiveError(QString)));connect(listen, SIGNAL(snapshot(QString, QTcpSocket *)), this, SLOT(slot_snapshot(QString, QTcpSocket *)));listen->setPara(flag, hard, serverIp, port, addr, rtspUrl);listen->setUserInfo(userName, userPwd);//处于启动中则启动if (isStart) {push->start();listen->start();}listFlag << flag;listHard << hard;listAddr << addr;listPush << push;listListen << listen;onvifSearch->setPara(listHard, listAddr);return true;
}void OnvifDeviceServer::remove(const QString &flag)
{int index = listFlag.indexOf(flag);if (index >= 0) {listPush.at(index)->stop();listPush.at(index)->deleteLater();listListen.at(index)->stop();listListen.at(index)->deleteLater();listFlag.removeAt(index);listAddr.removeAt(index);listPush.removeAt(index);listListen.removeAt(index);onvifSearch->setPara(listHard, listAddr);}
}void OnvifDeviceServer::clear()
{foreach (OnvifDevicePush *push, listPush) {push->stop();push->deleteLater();}foreach (OnvifDeviceListen *listen, listListen) {listen->stop();listen->deleteLater();}listFlag.clear();listAddr.clear();listPush.clear();listListen.clear();onvifSearch->setPara(listHard, listAddr);
}void OnvifDeviceServer::appendData(const QString &flag, const QByteArray &data)
{int index = listFlag.indexOf(flag);if (index >= 0) {listPush.at(index)->appendData(data);}
}void OnvifDeviceServer::slot_snapshot(const QString &flag, QTcpSocket *socket)
{int index = listFlag.indexOf(flag);if (index >= 0) {listPush.at(index)->snap(socket);}
}void OnvifDeviceServer::slot_pushStart(const QString &flag, int width, int height, bool start)
{emit pushStart(flag, width, height, start);int index = listFlag.indexOf(flag);if (index >= 0) {listListen.at(index)->setVideoInfo(25, width, height);}
}