新增视频监控内核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

@@ -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><>ѡvlc2<63><32>vlc3<63><33><EFBFBD><EFBFBD><EFBFBD>
6. <20><>ѡ32λ<32><CEBB>64λ<34><CEBB>vlc<6C><63>
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

@@ -1,9 +1,5 @@
#include "vlc.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"))
VlcThread::VlcThread(QObject *parent) : QThread(parent)
{
setObjectName("VlcThread");
@@ -34,7 +30,7 @@ void VlcThread::run()
free();
stopped = false;
isPlay = false;
//qDebug() << TIMEMS << "stop vlc thread";
//qDebug() << TIMEMS << "stop vlc1 thread";
}
void VlcThread::setUrl(const QString &url)
@@ -136,7 +132,7 @@ void VlcThread::stop()
//实时视频显示窗体类
VlcWidget::VlcWidget(QWidget *parent) : QWidget(parent)
{
vlc = new VlcThread(this);
thread = new VlcThread(this);
}
VlcWidget::~VlcWidget()
@@ -146,7 +142,7 @@ VlcWidget::~VlcWidget()
void VlcWidget::setUrl(const QString &url)
{
vlc->setUrl(url);
thread->setUrl(url);
}
void VlcWidget::open()
@@ -154,27 +150,27 @@ void VlcWidget::open()
//qDebug() << TIMEMS << "open video" << objectName();
clear();
vlc->play();
vlc->start();
thread->play();
thread->start();
}
void VlcWidget::pause()
{
vlc->pause();
thread->pause();
}
void VlcWidget::next()
{
vlc->next();
thread->next();
}
void VlcWidget::close()
{
//qDebug() << TIMEMS << "close video" << objectName();
if (vlc->isRunning()) {
vlc->stop();
vlc->quit();
vlc->wait(3000);
if (thread->isRunning()) {
thread->stop();
thread->quit();
thread->wait(3000);
}
QTimer::singleShot(5, this, SLOT(clear()));

View File

@@ -7,7 +7,6 @@
#endif
#include "vlchead.h"
class VlcWidget;
class VlcThread : public QThread
{
@@ -23,7 +22,6 @@ private:
volatile bool isPlay; //播放视频标志位
QString url; //视频流地址
libvlc_instance_t *vlcInst; //载体对象
libvlc_media_t *vlcMedia; //媒体对象
libvlc_media_player_t *vlcPlayer; //播放对象
@@ -60,7 +58,7 @@ public:
~VlcWidget();
private:
VlcThread *vlc; //实时视频采集对象
VlcThread *thread;
public slots:
//设置视频流地址

View File

@@ -1,6 +1,6 @@
HEADERS += $$PWD/vlchead.h
HEADERS += $$PWD/vlc.h
SOURCES += $$PWD/vlc.cpp
HEADERS += $$PWD/vlchead.h
HEADERS += $$PWD/vlc.h
SOURCES += $$PWD/vlc.cpp
#如果用的是vlc3内核请将vlc2改成vlc3,两种内核不兼容,头文件也不一样,建议用vlc2
DEFINES += vlc2

View File

@@ -1,37 +1,5 @@
/*****************************************************************************
* vlc.h: global header for libvlc
*****************************************************************************
* Copyright (C) 1998-2008 VLC authors and VideoLAN
* $Id: 8f39094bd4b15c99288cecd001f76fcc10565daa $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
* Gildas Bazin <gbazin@netcourrier.com>
* Derk-Jan Hartman <hartman at videolan dot org>
* Pierre d'Herbemont <pdherbemont@videolan.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_VLC_H
#define VLC_VLC_H 1
/**
* \file
* This file defines libvlc new external API
*/
#ifndef VLCHEAD_H
#define VLCHEAD_H 1
# ifdef __cplusplus
extern "C" {
@@ -68,4 +36,15 @@ extern "C" {
}
# endif
#endif /* _VLC_VLC_H */
#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 // VLCHEAD_H

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->vlcWidget->setUrl(url);
ui->vlcWidget->open();
ui->playWidget->setUrl(url);
ui->playWidget->open();
} else {
ui->btnOpen->setText("打开");
ui->vlcWidget->close();
ui->playWidget->close();
}
}

View File

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