One, foreword

In an article in the video files are stored and need to provide a convenient user query interface video file to playback, actually the playback is playing history store video files, and is not a thing on the tall, video playback points three in this system, the first is a local playback, playback stored in the client local video files; The second is remote playback, which uses the SDK provided by NVR manufacturers or the NATIONAL standard GB28181 protocol to play back the video files stored in NVR. The third is device playback (put in the device playback module), through the RTSP format to play back the video files stored in NVR, this is mainly convenient for third-party integration manufacturers to develop, after all, GB28181 protocol is more complex, debugging trouble, it is better to directly specify a specific RTSP format to play back the video. Of course, you need to bring the corresponding user authentication information in the requested RTSP address, otherwise there is no guarantee of security.

If it is stored using ffmpeg replay the store video files, and use ffmpeg directly open the file playback, have the freedom to control playback speed, being naked flow, the default soon, at the time of decoding is hard decoding, so just this feature provides the possibility of speed control, when decoding to rest a little, It’s like slowing down. If VLC is used for storage, the standard video files are stored, which can be opened and played directly by other players or played in the form of local files opened and played by VLC.

Local playback module, provides the query interface, first select a channel or all channel, and then choose the video type, has stored video and alarm video two kinds, usually the two are stored in separate folders, priority, finally choose the start time and end time, default is calculated according to the day, still can know, Choose good after click the query button will conform to the conditions listed all video files, double-click on one of these files can enable the play, a video was over, will automatically jump to the next file to continue to play, until the last file, interface provides a pause button, you can click to suspend the current broadcast video, can watch the progress of the play.

Two, functional characteristics

Software modules

  1. Video monitoring module, various docking small window sub-module, including device list, graphic warning, window information, panyt control, preset position, cruise setting, device 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 picture map, online map, offline map, path planning, etc.
  4. Log query module, including local logs, device logs, etc.
  5. System setting module, including system Settings (basic Settings, video parameters, database Settings, map configuration, serial port configuration, etc.), VIDEO recorder management, camera management, polling configuration, user management, etc.

Basis function

  1. Support various video streams (RTSP, RTMP, HTTP, etc.), video files (MP4, RMVB, AVI, etc.), local USB camera playback.
  2. Support multi-screen switching, including 1, 4, 6, 8, 9, 13, 16, 25, 36, 64 screen switching.
  3. Supports full-screen switching, including the right mouse button, toolbar button, and shortcut keys (Alt + Enter full-screen, esc exit full-screen).
  4. Supports video polling, including 1, 4, 9, and 16 screen polling. You can set polling group (polling plan), polling interval, and bit stream type.
  5. Supports the OnVIF protocol, including device search, pte control, device control (picture parameters, check time, system restart, capture pictures, etc.).
  6. Different users can have different module permissions, such as deleting logs and shutting down the system.
  7. Support a variety of databases, including sqlite, mysql, sqlserver, postgresql, oracle, rendajincang and so on.
  8. You can set resolution and frame rate for a local USB camera.
  9. All docking modules automatically generate corresponding menus to control the display and hide, in the title bar right click can pop up.
  10. Display all modules, hide all modules, reset the common layout, and reset the full-screen layout.
  11. Double-click the device to pop up real-time preview video, supporting picture map, online map, offline map, etc.
  12. The camera node can be dragged to the corresponding window to play the video, and the local file can be dragged to play the video.
  13. You can delete a video by right-clicking the mouse button, closing the floating bar, or dragging it outside the video surveillance panel.
  14. The device button on the picture map can be dragged freely to automatically save the location information. You can click the mouse to obtain the longitude and latitude information on the Baidu map to update the location of the device.
  15. Any channel in the video surveillance panel form supports drag exchange, instant response.
  16. Encapsulated Baidu map, view switch, movement track, equipment point, mouse click to obtain latitude and longitude.
  17. Double-click the node, drag the node, drag the window to switch positions and other operations, will automatically update and save the last playing address, the next software open automatic application.
  18. Volume bar control in the lower right corner, automatically hide when losing focus, volume strip mute icon.
  19. You can specify a screenshot for a single channel or all channels. The screenshot button is also available on the bottom toolbar.
  20. The mouse pointer can be automatically hidden when timeout expires and the mouse pointer can be automatically displayed in full screen.
  21. Support onVIF PTZ control, can move PTZ camera up, down, left and right, including reset and focal length adjustment.
  22. Support any ONVIF camera, including but not limited to Hikang, Dahua, Yushi, Weiye, Huawei, etc.
  23. Can save video, can select the time storage or single file storage, optional storage interval time.
  24. Video stream communication mode can be set TCP + UDP, video decoding can be set speed first, quality first, balance, etc.
  25. You can set the software name, English name, and LOGO icon.
  26. You can export stored video files to specific directories or upload them to servers in batches.

features

  1. The main interface adopts the mode of docked form, various components in the form of small modules, can be customized to join any module.
  2. Docking module can drag any position embedded and suspended, support maximum full screen, support multi-screen.
  3. Dual layout file storage mechanism, normal mode and full-screen mode are corresponding to different layout schemes, automatic switching and saving, for example, full-screen mode can highlight several modules transparent display in the specified position, more science fiction sense of modernization.
  4. Original onVIF protocol mechanism, using the underlying protocol resolution (UDP broadcast search + HTTP request execution command) more lightweight easy to understand learning expansion, does not rely on any third-party components such as GSOAP.
  5. Original data import and export mechanism, cross-platform independent of any components, instant data export.
  6. Built in multiple original components, the universe super value super awesome, Including data import and export components (export to XLS, PDF, printing), database components (database management thread, automatic data cleaning thread, universal paging, data request, etc.), map component, video monitoring component, file multithreading transceiver component, onVIF communication component, universal browser kernel component, etc.
  7. Customize information box + error box + query box + lower right prompt box (including various formats).
  8. Exquisite skin change, up to 17 sets of skin styles can be changed at will, all styles are unified, including menu, etc.
  9. Multiple buttons can be added to the video control hover bar, and 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 the video, it will automatically jump to the next, double click the parent node to automatically add all the videos under the node. Primary stream and sub-stream are optional.
  11. You can add, delete, and modify the import and export printed information, and immediately apply the new device information to generate a tree list without restarting.
  12. Optional a variety of kernel free switch, FFMPEG, VLC, MPV, etc., can be set in pro. Ffmpeg is recommended. It is most cross-platform and provides libraries compiled on Linux and MAC platforms by default.
  13. Supports hard decoding and can be set to hard decoding type (QSV, DXVA2, d3D11VA, etc.).
  14. The default opengL rendering video, ultra-low CPU resource consumption, support YUYV and NV12 two formats to draw, very awesome.
  15. Highly customizable, users can easily derive their own functions on this basis, such as adding custom modules, operation mode, robot monitoring, UAV monitoring, excavator monitoring, procuratorate trial monitoring, etc.
  16. Support XP, Win7, Win10, Linux, MAC, a variety of domestic systems (UOS, kyrin, Galaxy Kyrin, etc.), embedded Linux and other systems.
  17. Complete annotation, clear project structure, super detailed complete use of the development manual, accurate to the function description of each code file, continuous iteration version.

3. Experience address

  1. Experience address: pan.baidu.com/s/1d7TH_GEY… Extraction code: 01Jf File name: bin_video_system.zip
  2. Domestic site: gitee.com/feiyangqing…
  3. International site: github.com/feiyangqing…
  4. Profile: blog.csdn.net/feiyangqing…
  5. Zhihu homepage: www.zhihu.com/people/feiy…

Four, effect drawing

Five, core code

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

    // Convert the date to the number of days between the date and time. If the number exceeds 60 days, do not continue
    QDateTime dateTimeStart = ui->dateStart->dateTime(a); QDateTime dateTimeEnd = ui->dateEnd->dateTime(a);if (dateTimeStart.daysTo(dateTimeEnd) >= 60) {
        QUIHelper::showMessageBoxError("The maximum query time is 60 days!".3);
        return;
    }

    ui->listWidget->clear(a); QString videoPath;if (ui->cboxType->currentText() = ="Store video") {
        videoPath = QString("% % 1/2").arg(QUIHelper::appPath()).arg(DBData::VideoNormalPath);
    } else {
        videoPath = QString("% % 1/2").arg(QUIHelper::appPath()).arg(DBData::VideoAlarmPath);
    }

    // Obtain all folder names and query the videos of the corresponding channels according to the time
    // If the start time is less than or equal to the end time, add the video files in the folder corresponding to the start time to the list
    // Then add one day to the start time until it is longer than the end time
    while (dateStart <= dateEnd) {
        QString savePath = QString("% % 1/2").arg(videoPath).arg(dateStart.toString("yyyy-MM-dd"));
        QDir saveDir(savePath);
        QStringList filter;
        filter << "*.mp4" << "*.h264" ;
        QStringList files = saveDir.entryList(filter);

        foreach (QString file, files) {
            // If all channels are selected, the video files are not filtered
            if (ui->cboxCh->currentText() = ="All channels") {
                QListWidgetItem *item = new QListWidgetItem(ui->listWidget);
                item->setText(file);
                item->setData(Qt::UserRole, QString(savePath));
            } else {
                // Add the video file for the corresponding channel
                QString videoCh = file.split("-").at(6).split(".").at(0);
                QString chName = QString("Ch%1").arg(ui->cboxCh->currentIndex());
                if (videoCh == chName) {
                    QListWidgetItem *item = new QListWidgetItem(ui->listWidget);
                    item->setText(file);
                    item->setData(Qt::UserRole, QString(savePath));
                }
            }
        }

        dateStart = dateStart.addDays(1);
    }

    ui->labTip->setText(QString("Total found %1").arg(ui->listWidget->count()));
}

void frmVideoPlayLocal::on_btnPlayVideo_clicked(a)
{
    if (ui->listWidget->currentRow()"0) {
        return;
    }

    bool check = ui->btnPlayVideo->isChecked(a);if(! check) { IconHelper::Instance() - >setIcon(ui->btnPlayVideo, 0xf28d, btnRadius);
        widget->next(a); timerPlay->start(a); }else {
        IconHelper::Instance() - >setIcon(ui->btnPlayVideo, 0xf144, btnRadius);
        widget->pause(a); timerPlay->stop();
    }
}

void frmVideoPlayLocal::on_listWidget_doubleClicked(a)
{
    timerPlay->stop(a); QListWidgetItem *item = ui->listWidget->currentItem(a); QString file =QString("% % 1/2").arg(item->data(Qt::UserRole).toString()).arg(item->text());

    // Convert the file path to a path recognized by the operating system. Under Windows, the program call path outside Qt must be converted
    file = QDir::toNativeSeparators(file);

    < span style = "max-width: 100%; clear: both; min-height: 1em
    QFileInfo mp4File(file);
    QDateTime creatTime = mp4File.created(a); QDateTime lastTime = mp4File.lastModified(a);// If the creation time is longer than the last modification time, the file length is 0 or it is copied from the normal storage file.
    if (creatTime >= lastTime) {
        QUIHelper::showMessageBoxError("Abnormal storage video file, please select again!");
        return;
    }

    // Get the time difference in milliseconds
    qint64 milliSecondTime = creatTime.msecsTo(lastTime);
    int hour = milliSecondTime / (60 * 60 * 1000);
    int minute = (milliSecondTime - hour * 60 * 60 * 1000)/(60 * 1000);
    int seconds = (milliSecondTime - hour * 60 * 60 * 1000 - minute * 60 * 1000) / 1000;

    if (seconds >= 60) {
        seconds = seconds % 60;
        minute += seconds / 60;
    }

    if (minute >= 60) {
        minute = minute % 60;
        hour  += minute / 60;
    }

    // The playback duration is counted again
    hourPlay = 0;
    minutePlay = 0;
    secondsPlay = 0;
    secondsPlayCount = 0;
    timerPlay->start(a);// Reset the progress bar and the total duration
    currentVideoLenght = milliSecondTime / 1000;
    ui->slider->setMinimum(0);
    ui->slider->setMaximum(currentVideoLenght);
    ui->slider->setValue(0);
    ui->labTimeAll->setText(QString("Total duration: % 1h % 2min % 3sec").arg(hour).arg(minute).arg(seconds));

    // Release the last video before opening the current video
    widget->setUrl(file);
    widget->restart(a); currentVideo = file; ui->btnPlayVideo->setEnabled(true);
    ui->btnPlayVideo->setChecked(false);
    IconHelper::Instance() - >setIcon(ui->btnPlayVideo, 0xf28d, btnRadius);
}
Copy the code