一、前言說明
在銀行、超市、考試中心、工控系統、網課教學、居家辦公等場景中,傳統監控攝像頭難以清晰錄制電腦屏幕內容,導致關鍵操作無法有效追溯。為解決這一難題,我們推出了一套純軟件實現的電子屏幕監控方案,徹底取代依賴硬件視頻編碼器的傳統方式,實現高效、清晰、低成本的電腦屏幕錄像監控。
本方案基于虛擬攝像頭技術,將安裝了該軟件的電腦模擬為標準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);}
}