新增视频监控内核mpv

This commit is contained in:
feiyangqingyun
2020-08-27 15:38:51 +08:00
parent 5bd996668c
commit 2a80cb5392
39 changed files with 7790 additions and 110 deletions

View File

@@ -1,9 +1,5 @@
#include "ffmpeg.h"
#pragma execution_character_set("utf-8")
#define TIMEMS qPrintable(QTime::currentTime().toString("HH:mm:ss zzz"))
#define STRDATETIME qPrintable(QDateTime::currentDateTime().toString("yyyy-MM-dd-HH-mm-ss"))
FFmpegThread::FFmpegThread(QObject *parent) : QThread(parent)
{
setObjectName("FFmpegThread");
@@ -360,8 +356,8 @@ void FFmpegThread::stop()
//实时视频显示窗体类
FFmpegWidget::FFmpegWidget(QWidget * parent) : QWidget(parent)
{
ffmpeg = new FFmpegThread(this);
connect(ffmpeg, SIGNAL(receiveImage(QImage)), this, SLOT(updateImage(QImage)));
thread = new FFmpegThread(this);
connect(thread, SIGNAL(receiveImage(QImage)), this, SLOT(updateImage(QImage)));
image = QImage();
}
@@ -390,7 +386,7 @@ void FFmpegWidget::updateImage(const QImage &image)
void FFmpegWidget::setUrl(const QString &url)
{
ffmpeg->setUrl(url);
thread->setUrl(url);
}
void FFmpegWidget::open()
@@ -398,27 +394,27 @@ void FFmpegWidget::open()
//qDebug() << TIMEMS << "open video" << objectName();
clear();
ffmpeg->play();
ffmpeg->start();
thread->play();
thread->start();
}
void FFmpegWidget::pause()
{
ffmpeg->pause();
thread->pause();
}
void FFmpegWidget::next()
{
ffmpeg->next();
thread->next();
}
void FFmpegWidget::close()
{
//qDebug() << TIMEMS << "close video" << objectName();
if (ffmpeg->isRunning()) {
ffmpeg->stop();
ffmpeg->quit();
ffmpeg->wait(500);
if (thread->isRunning()) {
thread->stop();
thread->quit();
thread->wait(500);
}
QTimer::singleShot(1, this, SLOT(clear()));

View File

@@ -7,7 +7,6 @@
#endif
#include "ffmpeghead.h"
class FFmpegWidget;
class FFmpegThread : public QThread
{
@@ -81,8 +80,8 @@ protected:
void paintEvent(QPaintEvent *);
private:
FFmpegThread *ffmpeg; //实时视频采集对象
QImage image; //要显示的图片
FFmpegThread *thread;
QImage image;
private slots:
//接收图像并绘制

View File

@@ -1,6 +1,6 @@
HEADERS += $$PWD/ffmpeghead.h
HEADERS += $$PWD/ffmpeg.h
SOURCES += $$PWD/ffmpeg.cpp
HEADERS += $$PWD/ffmpeghead.h
HEADERS += $$PWD/ffmpeg.h
SOURCES += $$PWD/ffmpeg.cpp
#如果用的是ffmpeg4内核请将ffmpeg3改成ffmpeg4,两种内核不兼容,头文件也不一样
DEFINES += ffmpeg3

View File

@@ -1,4 +1,7 @@
//必须加以下内容,否则编译不能通过,为了兼容C和C99标准
#ifndef FFMPEGHEAD_H
#define FFMPEGHEAD_H
//必须加以下内容,否则编译不能通过,为了兼容C和C99标准
#ifndef INT64_C
#define INT64_C
#define UINT64_C
@@ -15,6 +18,7 @@ extern "C" {
#include "libavutil/ffversion.h"
#include "libavcodec/avcodec.h"
#include "libswscale/swscale.h"
#include "libswresample/swresample.h"
#include "libavformat/avformat.h"
#include "libavfilter/avfilter.h"
@@ -27,3 +31,16 @@ extern "C" {
#include "libavutil/hwcontext_qsv.h"
#endif
}
#include "qdatetime.h"
#pragma execution_character_set("utf-8")
#define TIMEMS qPrintable(QTime::currentTime().toString("HH:mm:ss zzz"))
#define TIME qPrintable(QTime::currentTime().toString("HH:mm:ss"))
#define QDATE qPrintable(QDate::currentDate().toString("yyyy-MM-dd"))
#define QTIME qPrintable(QTime::currentTime().toString("HH-mm-ss"))
#define DATETIME qPrintable(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"))
#define STRDATETIME qPrintable(QDateTime::currentDateTime().toString("yyyy-MM-dd-HH-mm-ss"))
#define STRDATETIMEMS qPrintable(QDateTime::currentDateTime().toString("yyyy-MM-dd-HH-mm-ss-zzz"))
#endif // FFMPEGHEAD_H

View File

@@ -6,12 +6,4 @@
2. <20><><EFBFBD><EFBFBD>վ<EFBFBD>㣺[https://gitee.com/feiyangqingyun](https://gitee.com/feiyangqingyun)
3. <20><><EFBFBD><EFBFBD>վ<EFBFBD>㣺[https://github.com/feiyangqingyun](https://github.com/feiyangqingyun)
4. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>[https://blog.csdn.net/feiyangqingyun](https://blog.csdn.net/feiyangqingyun)
5. ֪<><D6AA><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>[https://www.zhihu.com/people/feiyangqingyun/](https://www.zhihu.com/people/feiyangqingyun/)
1. <20><><EFBFBD>߳<EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>
2. ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
3. ֧<><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Qt<51><EFBFBD><E6B1BE><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
4. <20><><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBA3AC>չ<EFBFBD><D5B9>ǿ
5. <20><>ѡffmpeg3<67><33>ffmpeg4<67><34><EFBFBD><EFBFBD><EFBFBD>
6. <20><>ѡ32λ<32><CEBB>64λ<34><CEBB>ffmpeg<65><67>
7. ע<>;<EFBFBD><CDBE><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
5. ֪<><D6AA><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>[https://www.zhihu.com/people/feiyangqingyun/](https://www.zhihu.com/people/feiyangqingyun/)

View File

@@ -2,9 +2,7 @@
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
{
ui->setupUi(this);
@@ -17,6 +15,7 @@ Widget::Widget(QWidget *parent)
urls << "rtsp://192.168.1.247:554/av0_0";
urls << "rtsp://192.168.1.247:554/av0_1";
ui->cboxUrl->addItems(urls);
ui->cboxUrl->setCurrentIndex(5);
}
Widget::~Widget()
@@ -29,10 +28,10 @@ void Widget::on_btnOpen_clicked()
if (ui->btnOpen->text() == "打开") {
ui->btnOpen->setText("关闭");
QString url = ui->cboxUrl->currentText().trimmed();
ui->ffmpegWidget->setUrl(url);
ui->ffmpegWidget->open();
ui->playWidget->setUrl(url);
ui->playWidget->open();
} else {
ui->btnOpen->setText("打开");
ui->ffmpegWidget->close();
ui->playWidget->close();
}
}

View File

@@ -15,7 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="FFmpegWidget" name="ffmpegWidget" native="true">
<widget class="FFmpegWidget" name="playWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>