当前位置:网站首页>QT compiling security video monitoring system 44 video uploading

QT compiling security video monitoring system 44 video uploading

2022-06-12 04:22:00 qq60b6d1b681847


One 、 Preface

Video upload is used to upload locally stored video files to the cloud server , Indirectly realize the function of storing local video to the cloud , In fact, it is stored locally first , After the file is generated, upload it to the cloud , The final effect is the same , To expand compatibility , A separate video upload module is directly made , You can select the video file to upload on the interface and check , You can query by date and time , Channel query, etc , You can customize the address and port of the cloud server , Click one click upload to see the upload progress of each video file . They all use multi-threaded uploading , You can upload multiple files at the same time , Each file has a file size and upload progress display . At present, they are all uploaded manually , Automatic uploading mechanism can be added in the later stage , Listen for folder changes ( Once a change occurs, find the corresponding newly added video file ) Or file storage completion signal , Trigger upload immediately .

Video upload features


  • Multithreading to send and receive files , Support encrypted transmission .
  • The receiver supports two ways: listening port receiving files and active connection server receiving files .
  • according to File start + file size + The contents of the document + End of file Receive one by one by subcontracting .
  • It can decrypt and output the received encrypted file package .
  • If the file is received by connecting to the server, the request file can be specified .
  • The form of the request file of the receiver can be used as a general program upgrade scheme .
  • The progress bar updates the progress of sending and receiving files in real time .
  • The sender can set the maximum size of each packet, that is, the number of slices and packets .
  • The sender can encrypt each packet of the file .
  • The sender supports merging and sending packets .
  • You can specify a directory to search the request file sent by the client .
  • Each function is an independent class , The interface is clear and friendly , Easy to use .
  • Support any Qt edition 、 Any system 、 Any compiler .

Two 、 Functional characteristics

( One ) Software modules


  1. Video monitoring module , All kinds of small window body sub modules , Including a list of devices 、 Picture and text police information 、 Window information 、 Pan tilt control 、 Preset position 、 Cruise settings 、 Equipment control 、 Floating map 、 Web browsing, etc .
  2. Video playback module , Including local playback 、 Remote playback 、 Device playback 、 Picture playback 、 Video upload, etc .
  3. Electronic map module , Including pictures, maps 、 Online map 、 offline map 、 Path planning, etc .
  4. Log query module , Including local logs 、 Device logs, etc .
  5. System setup module , Including system settings ( Basic settings 、 Video parameters 、 Database settings 、 Map configuration 、 Serial port configuration, etc )、 VCR Management 、 Camera Management 、 Polling configuration 、 User management, etc .

( Two ) Basic function


  1. Supports various video streams (rtsp、rtmp、http etc. )、 Video file (mp4、rmvb、avi etc. )、 Local USB The camera plays .
  2. Support multi screen switching , Include 1、4、6、8、9、13、16、25、36、64 Screen switching .
  3. Support full screen switching , A variety of switching methods, including the right mouse button menu 、 toolbar button 、 Shortcut key (alt+enter Full screen ,esc Exit full screen ).
  4. Support video polling , Include 1、4、9、16 Screen polling , Polling groups can be set ( Polling plan )、 Polling interval 、 Stream type, etc .
  5. Support onvif agreement , Including device search 、 Pan tilt control 、 Equipment control ( Picture parameters 、 Proofreading time 、 System restart , Capture pictures, etc ).
  6. Support rights management , Different users can have different module permissions , Like deleting logs 、 Shut down the system, etc .
  7. The database supports a variety of , Include sqlite、mysql、sqlserver、postgresql、oracle、 People's Congress, Jincang, etc .
  8. Local USB The camera supports setting resolution 、 Frame rate and other parameters .
  9. All docking modules automatically generate corresponding menus to control display and hide , Right click in the title bar to pop up .
  10. Support to display all modules 、 Hide all modules 、 Reset normal layout 、 Reset full screen layout .
  11. Double click the device to pop up the real-time preview video , Support image map 、 Online map 、 Offline maps, etc .
  12. Drag the camera node to the corresponding window to play video , At the same time, it supports dragging local files to play directly .
  13. Delete video support right mouse button delete 、 Floating bar close delete 、 Drag it outside the video monitoring panel to delete it .
  14. The device button on the picture map can be dragged freely , Automatically save location information . Baidu map can click the mouse to obtain longitude and latitude information , Used to update device location .
  15. Any channel in the form of video monitoring panel supports drag and drop switching , Instant response .
  16. It encapsulates Baidu map , views switching , path of particle , Equipment points , Click the mouse to get the latitude and longitude .
  17. Double click the node 、 Drag nodes 、 Drag the form, swap the position, etc , Automatically update and save the last playback address , Next time the software opens the automatic application .
  18. Lower right volume bar control , Lose focus auto hide , Volume bar mute icon .
  19. Support video capture , You can specify a single or all channel screenshot , There's also a screenshot button on the bottom toolbar .
  20. Support timeout auto hide mouse pointer 、 Automatic full screen mechanism .
  21. Support onvif Pan tilt control , The camera can be moved up and down , Including reset and focus adjustment .
  22. Support any onvif The camera , Including but not limited to Haikang 、 Dahua 、 Depending Yu 、 The great cause of heaven and earth 、 HUAWEI, etc. .
  23. Can save video , It can be stored in a fixed time or in a single file , Optional storage interval time .
  24. Video stream communication mode can be set tcp+udp, Video decoding can be set to speed first 、 Quality first 、 Equilibrium, etc .
  25. Chinese name of software can be set 、 English name 、LOGO Icon, etc .
  26. The stored video files can be exported to the specified directory , Support batch upload to the server .

( 3、 ... and ) Special function


  1. The main interface adopts the docking form mode , Various components are added in the form of small modules , You can customize any module to add .
  2. Docking module can drag any position to embed and suspend , Support maximum full screen , Support multi screen .
  3. Dual layout file storage mechanism , Normal mode 、 Full screen mode corresponds to different layout schemes , Auto switch and save , For example, in full screen mode, several modules can be highlighted and displayed transparently in designated positions , More sci-fi, modern .
  4. original onvif Protocol mechanism , Using the underlying protocol analysis (udp Radio search +http Request to execute command ) It's lighter, easier to understand, easier to learn and expand , It doesn't rely on any third-party components, such as gsoap.
  5. Original data import and export mechanism , Cross platform does not rely on any components , Export data instantaneously .
  6. Built in multiple original components , The universe is worth a lot , Including data import and export components ( Export to xls、pdf、 Print )、 Database components ( Database management thread 、 Automatically clean up data threads 、 Universal paging 、 Data request, etc )、 Map components 、 Video surveillance components 、 File multithreading transceiver component 、onvif Communication components 、 General browser kernel components, etc .
  7. Custom message box + Error box + Inquiry frame + Prompt box in the lower right corner ( Contains multiple formats ) etc. .
  8. Beautiful skin change , the height is 17 Change the skin style at will , All styles are unified , Including menu, etc .
  9. Video control suspension bar can add multiple buttons by itself , Buttons can also be added to the small toolbar at the bottom of the monitoring interface .
  10. Double click the camera node to automatically play the video , Double click the node to automatically add videos one by one , Will automatically jump to the next , Double click the parent node to automatically add all videos under the node . Optional main stream 、 Sub-stream .
  11. VCR Management 、 Camera Management , You can add, delete, modify, import, export and print information , Apply the new device information to generate the tree list immediately , No need to restart .
  12. Multiple kernels can be selected to switch freely ,ffmpeg、vlc、mpv etc. , Can be found in pro Set in . Recommend to use ffmpeg, Cross platform is the most , By default linux and mac Compiled libraries on the platform .
  13. Support hard decoding , Hard decoding type can be set (qsv、dxva2、d3d11va etc. ).
  14. By default opengl Drawing video , Ultra low CPU Resource occupation , Support yuyv and nv12 Two formats to draw , It's awesome .
  15. Highly customizable , Users can easily derive their own functions on this basis , For example, add a custom module , Add operation mode 、 Robot monitoring 、 Drone monitoring 、 Excavator monitoring, etc .
  16. Support xp、win7、win10、linux、mac、 All kinds of domestic systems (UOS、 Winning Qilin 、 Galaxy unicorn, etc )、 The embedded linux Such as system .
  17. Note complete , The project structure is clear , Super detailed complete use of the development manual , Accurate to the function description of each code file , Keep iterating over versions .

3、 ... and 、 Experience address


  1. Experience address :​ ​https://pan.baidu.com/s/1d7TH_GEYl5nOecuNlWJJ7g​​ Extraction code :01jf file name :bin_video_system.zip.
  2. Domestic site :​ ​https://gitee.com/feiyangqingyun​
  3. International sites :​ ​https://github.com/feiyangqingyun​
  4. Zhihu Homepage :​ ​https://www.zhihu.com/people/feiyangqingyun/​
  5. Online document :​ ​https://feiyangqingyun.gitee.io/qwidgetdemo/video_system/​

Four 、 design sketch

Qt Write security video monitoring system 44- Video uploading _Qt Video surveillance

5、 ... and 、 Core code

       
void frmVideoUpload::addItem(const QString &name, const QString &data)
{
int row = fileNames.count();
QString fileName = data + "/" + name;
fileNames << fileName;

// Check box , If all is checked, the current equipment will be automatically selected
QCheckBox *itemCk = new QCheckBox(this);
itemCk->setChecked(ckAll->isChecked());

// Add file name
QTableWidgetItem *itemFile = new QTableWidgetItem;
itemFile->setText(name);
itemFile->setData(Qt::UserRole, QString(data));
itemFile->setTextAlignment(Qt::AlignCenter);

// Add file size
QTableWidgetItem *itemSize = new QTableWidgetItem;
quint64 size = QFile(fileName).size();
itemSize->setText(TcpFileHelper::getFileSizeMB(size));
itemSize->setTextAlignment(Qt::AlignCenter);

// Adding unit
QTableWidgetItem *itemUnit = new QTableWidgetItem;
itemUnit->setText("MB");
itemUnit->setTextAlignment(Qt::AlignCenter);

// Add progress bar
QProgressBar *itemBar = new QProgressBar(this);
itemBar->setRange(0, size);
itemBar->setValue(0);

ui->tableWidget->setCellWidget(row, 0, itemCk);
ui->tableWidget->setItem(row, 1, itemFile);
ui->tableWidget->setItem(row, 2, itemSize);
ui->tableWidget->setItem(row, 3, itemUnit);
ui->tableWidget->setCellWidget(row, 4, itemBar);
}

void frmVideoUpload::on_btnSelect_clicked()
{
QDate dateStart = ui->dateStart->date();
QDate dateEnd = ui->dateEnd->date();
if (dateStart > dateEnd) {
QUIHelper::showMessageBoxError(" The start time cannot be greater than the end time !", 3);
return;
}

// Convert date to date time to calculate the number of days difference , If the maximum number of days is exceeded, you will be prompted not to continue
if (dateStart.daysTo(dateEnd) >= 60) {
QUIHelper::showMessageBoxError(" You can only query at most at a time 60 Days. !", 3);
return;
}

fileNames.clear();
ui->tableWidget->clearContents();
QString filePath;
if (ui->cboxType->currentText() == " Store video ") {
filePath = AppData::VideoNormalPath;
} else {
filePath = AppData::VideoAlarmPath;
}

// Get all folder names , Query the corresponding channel type video according to the time
// If the start time is less than or equal to the end time , Then add the video files under the folder corresponding to the start time to the list
// Then add one day to the start time , Until greater than the end time
while (dateStart <= dateEnd) {
// Generate a folder corresponding to the date
QString savePath = QString("%1/%2").arg(filePath).arg(dateStart.toString("yyyy-MM-dd"));
QDir saveDir(savePath);
// Determine whether the folder exists
if (saveDir.exists()) {
// Specify file extension filtering , Sort in ascending chronological order
QStringList filter;
filter << "*.mp4" << "*.h264";
QStringList names = saveDir.entryList(filter, QDir::NoFilter, QDir::Time | QDir::Reversed);

foreach (QString name, names) {
// If it's all the channels of choice , Do not filter video files
if (ui->cboxCh->currentText() == " All channels ") {
addItem(name, savePath);
} else {
// Add the video file of the corresponding channel
QString videoCh = name.split("_").first();
QString chName = QString("Ch%1").arg(ui->cboxCh->currentIndex());
if (videoCh == chName) {
addItem(name, savePath);
}
}
}
}

dateStart = dateStart.addDays(1);
}
}

void frmVideoUpload::on_btnUpload_clicked()
{
// Filter selected files
int fileCount = fileNames.count();
QList<QString> files;
QList<QProgressBar *> bars;
for (int row = 0; row < fileCount; row++) {
QString fileName = fileNames.at(row);
QCheckBox *itemCk = (QCheckBox *)ui->tableWidget->cellWidget(row, 0);
QProgressBar *bar = (QProgressBar *)ui->tableWidget->cellWidget(row, 4);
bar->setValue(0);
if (itemCk && itemCk->isChecked()) {
files << fileName;
bars << bar;
}
}

int count = files.count();
if (count == 0) {
QUIHelper::showMessageBoxError(" No device selected !", 3);
return;
}

// Each upload has a thread
for (int i = 0; i < count; i++) {
TcpSendFileThread *sendFileThread = new TcpSendFileThread(this);
sendFileThread->setFileName(fileNames.at(i));
// If the network is not good, you can adjust the size of the packets sent each time
sendFileThread->setMaxPackageSize(0xFFFF);
sendFileThread->setReceiveIP(AppConfig::UploadHost);
sendFileThread->setReceivePort(AppConfig::UploadPort);
sendFileThread->setProgressBar(bars.at(i));
sendFileThread->start();
}
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.



原网站

版权声明
本文为[qq60b6d1b681847]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203011011229306.html