一般视频回放都会采用GB28181国标来处理,这样可以保证兼容国内各大厂家的NVR,毕竟在同一的国家标准下,大家都会统一支持国标的,就不需要根据各个厂家的SDK来做兼容处理,烦得很,厂家越来越多,SDK也越来越多,每个厂家的接口未必一致,还要重新封装SDK来处理。
我这个上面为了简化处理,并未加入GB28181的处理,交由用户自己去处理,我只是单纯的播放个视频文件作为demo,提供视频回放控件,用于标识每个通道,某些时间段有时间,提供游标用于快速定位视频位置,直接跳过去。
体验地址:https://pan.baidu.com/s/1bbL2ZughZAgfIGrexyN-9g 提取码:zkeh 。
监控系统是由摄像、传输、控制、显示、记录登记5大部分组成。摄像机通过同轴视频电缆将视频图像传输到控制主机,控制主机再将视频信号分配到各监视器及录像设备,同时可将需要传输的语音信号同步录入到录像机内。 通过控制主机,操作人员可发出指令,对云台的上、下、左、右的动作进行控制及对镜头进行调焦变倍的操作,并可通过控制主机实现在多路摄像机及云台之间的切换。利用特殊的录像处理模式,可对图像进行录入、回放、处理等操作,使录像效果达到最佳。
视频监控系统由实时控制系统、监视系统及管理信息系统组成。实时控制系统完成实时数据采集处理、存储、反馈的功能;监视系统完成对各个监控点的全天候的监视,能在多操作控制点上切换多路图像;管理信息系统完成各类所需信息的采集、接收、传输、加工、处理,是整个系统的控制核心。视频监控系统是安全防范系统的组成部分,它是一种防范能力较强的综合系统。视频监控以其直观、方便、信息内容丰富而广泛应用于许多场合。
#include "frmvideoplayback.h"
#include "ui_frmvideoplayback.h"
#include "quiwidget.h"
#include "iconfont.h"
#include "videowidget.h"
#ifdef videovlc
#include "vlc.h"
#elif videoffmpeg
#include "ffmpeg.h"
#elif easyplayer
#include "easyplayer.h"
#endif
frmVideoPlayback::frmVideoPlayback(QWidget *parent) : QWidget(parent), ui(new Ui::frmVideoPlayback)
{
ui->setupUi(this);
this->initForm();
this->initIcon();
this->initData();
this->initVideo();
//QTimer::singleShot(1000, this, SLOT(play_video_all()));
}
frmVideoPlayback::~frmVideoPlayback()
{
delete ui;
}
void frmVideoPlayback::showEvent(QShowEvent *)
{
this->initData();
}
bool frmVideoPlayback::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::MouseButtonDblClick) {
if (watched->inherits("QWidget")) {
QWidget *widget = (QWidget *) watched;
if (!videoMax) {
videoMax = true;
hide_video_all();
widget->setVisible(true);
} else {
videoMax = false;
show_video_all();
}
widget->setFocus();
}
}
return QWidget::eventFilter(watched, event);
}
void frmVideoPlayback::initForm()
{
ui->navTree->setText("通道回放");
ui->navTree->setLeftIcon(0xf002);
ui->navTree->setRightIcon5(0xf067);
for (int i = 1; i <= 16; i++) {
ui->cboxCh->addItem(QString("通道%1").arg(i));
}
QStringList types;
types << "运行视频" << "报警视频";
ui->cboxType->addItems(types);
QStringList speeds;
speeds << "半倍速度" << "正常速度" << "二倍速度" << "四倍速度" << "八倍速度" << "十六倍速度";
ui->cboxSpeed->addItems(speeds);
ui->cboxSpeed->setCurrentIndex(1);
ui->dateTimeStart->calendarWidget()->setLocale(QLocale::Chinese);
ui->dateTimeEnd->calendarWidget()->setLocale(QLocale::Chinese);
ui->dateTimeStart->setDate(QDate::currentDate());
ui->dateTimeEnd->setDate(QDate::currentDate().addDays(1));
}
void frmVideoPlayback::initIcon()
{
quint32 size = 15;
quint32 pixWidth = 20;
quint32 pixHeight = 15;
QSize iconSize = QSize(pixWidth, pixHeight);
QPixmap pix1 = IconHelper::Instance()->getPixmap(QUIConfig::TextColor, 0xf002, size, pixWidth, pixHeight);
QPixmap pix2 = IconHelper::Instance()->getPixmap(QUIConfig::TextColor, 0xf019, size, pixWidth, pixHeight);
QPixmap pix3 = IconHelper::Instance()->getPixmap(QUIConfig::TextColor, 0xf00d, size, pixWidth, pixHeight);
QPixmap pix4 = IconHelper::Instance()->getPixmap(QUIConfig::TextColor, 0xf1f8, size, pixWidth, pixHeight);
ui->btnSelect->setIconSize(iconSize);
ui->btnDown->setIconSize(iconSize);
ui->btnDelete->setIconSize(iconSize);
ui->btnClear->setIconSize(iconSize);
ui->btnSelect->setIcon(QIcon(pix1));
ui->btnDown->setIcon(QIcon(pix2));
ui->btnDelete->setIcon(QIcon(pix3));
ui->btnClear->setIcon(QIcon(pix4));
}
void frmVideoPlayback::initData()
{
ui->listWidget->clear();
for (int i = 0; i < 10; i++) {
QListWidgetItem *item = new QListWidgetItem(ui->listWidget);
item->setText(QString("%1 - %2").arg(DATETIME).arg("7分53秒"));
item->setCheckState(Qt::Checked);
}
}
void frmVideoPlayback::initVideo()
{
videoMax = false;
videoCount = 4;
for (int i = 0; i < App::VideoCount; i++) {
#ifdef videovlc
VlcWidget *widget = new VlcWidget;
widget->setCallback(true);
//widget->setHardware("auto");
#elif videoffmpeg
FFmpegWidget *widget = new FFmpegWidget;
//widget->setHardware("d3d11va");
#elif easyplayer
EasyPlayerWidget *widget = new EasyPlayerWidget;
#else
VideoWidget *widget = new VideoWidget;
#endif
//设置背景文字
widget->setBgText(QString("通道 %1").arg(i + 1));
//设置背景图片
widget->setBgImage(QImage(":/bg_novideo.png"));
//设置url地址
widget->setUrl("");
//设置悬浮条可见
widget->setFlowEnable(false);
//设置是否自动重连
widget->setCheckLive(false);
widget->installEventFilter(this);
widget->setObjectName(QString("video%1").arg(i + 1));
widgets.append(widget);
}
//加入到布局中
ui->gridLayout->addWidget(widgets.at(0), 0, 0);
ui->gridLayout->addWidget(widgets.at(1), 0, 1);
ui->gridLayout->addWidget(widgets.at(2), 1, 0);
ui->gridLayout->addWidget(widgets.at(3), 1, 1);
}
void frmVideoPlayback::play_video_all()
{
//举例数据
widgets.at(0)->setUrl("g:/mp5/1.asf");
widgets.at(1)->setUrl("g:/mp5/2.asf");
widgets.at(2)->setUrl("g:/mp5/3.asf");
widgets.at(3)->setUrl("g:/mp5/4.asf");
QTimer::singleShot(0, widgets.at(0), SLOT(open()));
QTimer::singleShot(1000, widgets.at(1), SLOT(open()));
QTimer::singleShot(2000, widgets.at(2), SLOT(open()));
QTimer::singleShot(3000, widgets.at(3), SLOT(open()));
VideoCh::VideoData data1, data2, data3, data4;
data1.startX = 30;
data1.length = 150;
data2.startX = 200;
data2.length = 50;
data3.startX = 280;
data3.length = 100;
ui->videoPlayback->setDatas1(QList() << data1 << data2 << data3);
data4.startX = 30;
data4.length = 380;
ui->videoPlayback->setDatas2(QList() << data4);
ui->videoPlayback->setDatas3(QList() << data4);
ui->videoPlayback->setDatas4(QList() << data4);
}
void frmVideoPlayback::show_video_all()
{
for (int i = 0; i < videoCount; i++) {
widgets.at(i)->setVisible(true);
}
}
void frmVideoPlayback::hide_video_all()
{
for (int i = 0; i < videoCount; i++) {
widgets.at(i)->setVisible(false);
}
}
void frmVideoPlayback::on_listWidget_itemPressed(QListWidgetItem *item)
{
bool checked = (item->checkState() == Qt::Checked);
item->setCheckState(checked ? Qt::Unchecked : Qt::Checked);
}