mainwindow.cpp:
Code: Select all
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
VlcCommon::setPluginPath(qApp->applicationDirPath() + "/plugins");
VlcInstance *instance = new VlcInstance(VlcCommon::args(), NULL);
VlcMediaPlayer *player = new VlcMediaPlayer(instance);
//Show on QT GUI
player->setVideoWidget(ui->video);
ui->video->setMediaPlayer(player);
VlcMedia *media = new VlcMedia("/debug/sample-mp4-file.mp4", true, instance);
player->open(media);
}
FrameProcessor.h:
Code: Select all
#include <QtCore/QDebug>
#include "src/core/VideoStream.h"
class VlcFrameProcessor : public VlcVideoStream
{
public:
VlcFrameProcessor(QObject *parent);
virtual void frameUpdated();
};
Code: Select all
#include "FrameProcessor.h"
VlcFrameProcessor::VlcFrameProcessor(QObject *parent) : VlcVideoStream(Vlc::YUVFormat, parent){ }
void VlcFrameProcessor::frameUpdated() {
qDebug() << "frame update.";
QByteArray byteArray = this->renderFrame()->frameBuffer;
quint16 width, height;
memcpy(&width, &(this->renderFrame()->width), sizeof (quint16));
memcpy(&height, &(this->renderFrame()->height), sizeof (quint16));
qDebug() << "frame w:" << width << " h:" << height;
}
Code: Select all
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
VlcCommon::setPluginPath(qApp->applicationDirPath() + "/plugins");
VlcInstance *instance = new VlcInstance(VlcCommon::args(), NULL);
VlcMediaPlayer *player = new VlcMediaPlayer(instance);
//Show on QT GUI
player->setVideoWidget(ui->video);
ui->video->setMediaPlayer(player);
//I only add 2 lines!
VlcFrameProcessor *mProcessor = new VlcFrameProcessor(NULL);
mProcessor->init(player);
VlcMedia *media = new VlcMedia("/debug/sample-mp4-file.mp4", true, instance);
player->open(media);
}
However, it causes the screen became ALL GREEN and all content of frameBuffer are always 20 as the picture below...
https://imgur.com/a/iUOZqEJ
By the way, it don't affect the audio, which still can play well.
Any help will be highly appreciated!
PS. I'm not sure if I can post the QT-VLC issue here. If it can't, please notify me. Thanks!