1. 增加猫眼镜头切换IRCUT; 2. 优化连续多次打开视频获取视频流导致的内存问题

This commit is contained in:
2024-09-02 18:37:24 +08:00
parent 09c5843358
commit 15eb213578
19 changed files with 153 additions and 181 deletions

View File

@@ -33,7 +33,7 @@ FFmpegDecoder::~FFmpegDecoder()
void FFmpegDecoder::processVideo(int itemIndex)
{
#if 0
#if 1
int width = 720;
int height = 1280;
#elif 1
@@ -43,6 +43,7 @@ void FFmpegDecoder::processVideo(int itemIndex)
int width = 480;
int height = 640;
#endif
qDebug() << "------ processVideo";
if (width * 16 == height * 9) {
FocusWindowDialog* dialog = new FocusWindowDialog(nullptr, QSize(540, 960));
dialog->exec();
@@ -75,11 +76,12 @@ void FFmpegDecoder::stopFFmpegDecoder()
mutex.unlock();
}
void FFmpegDecoder::decodeFile(const QString& filePath, QLabel* videoDisplayLabel)
void FFmpegDecoder::decodeFile(const QString& videoFilePath, QLabel* videoDisplayLabel, QLineEdit* VideoResolutionEdit)
{
QMutexLocker locker(&mutex);
this->filePath = filePath;
this->videoLabel = videoDisplayLabel;
this->filePath = videoFilePath;
this->videoLabel = videoDisplayLabel;
this->resolutionEdit = VideoResolutionEdit;
if (!isRunning()) {
qDebug() << "Starting decoder thread";
start(NormalPriority);
@@ -107,8 +109,8 @@ void FFmpegDecoder::run()
QSize labelSize = currentVideoLabel->size();
mutex.unlock();
if (labelSize.width() < 740 || labelSize.height() < 357) {
labelSize = QSize(740, 357);
if (labelSize.width() < 220 || labelSize.height() < 357) {
labelSize = QSize(220, 357);
currentVideoLabel->setFixedSize(labelSize);
qDebug() << "Adjusting video label size to: Width =" << labelSize.width() << ", Height =" << labelSize.height();
}
@@ -275,7 +277,9 @@ QImage FFmpegDecoder::avFrameToQImage(AVFrame* frame)
{
int width = frame->width;
int height = frame->height;
qDebug() << "H264 video resolution: Width =" << frame->width << ", Height =" << frame->height;
QString resolutionText = QString::number(width) + " x " + QString::number(height);
resolutionEdit->setText(resolutionText);
//qDebug() << "H264 video resolution: Width =" << frame->width << ", Height =" << frame->height;
AVPixelFormat pixFmt = (AVPixelFormat)frame->format;

View File

@@ -15,6 +15,7 @@
#include <cstdint>
#include <vector>
#include <QDir>
#include <QLineEdit>
#include "RingBuffer.h"
#include "FocusWindow.h"
@@ -38,7 +39,7 @@ public:
~FFmpegDecoder() override;
void initialize();
void decodeFile(const QString& filePath, QLabel* videoLabel);
void decodeFile(const QString& videoFilePath, QLabel* videoLabel, QLineEdit* VideoResolutionEdit);
void decodeSingleFrame(const QByteArray& data, QLabel* videoLabel); // 添加 videoLabel 参数
void FFmpegDecoder::processVideo(int itemIndex);
bool initializeFFmpeg(const QString& filePath);
@@ -55,6 +56,7 @@ private:
QWaitCondition condition;
QString filePath;
QLabel* videoLabel;
QLineEdit* resolutionEdit;
bool abort;
bool restart;