[vlc-qt] Get wrong frame buffer

This forum is about all development around libVLC.
hughesyang
New Cone
New Cone
Posts: 1
Joined: 29 Sep 2021 09:53

[vlc-qt] Get wrong frame buffer

Postby hughesyang » 29 Sep 2021 11:06

Hi, I referred vlc-qt https://github.com/vlc-qt & vlc-qt examples simple-player https://github.com/vlc-qt/examples/tree ... ple-player with VLC 3.0.16 https://get.videolan.org/vlc/3.0.16/win64/ to create a small player. Finally, It can play video on VlcWidgetVideo!
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); }
Now, I want to get the frame buffer to do something. I referred some articles. I created a sub-class which inherits from VlcVideoStream class & implemented frameUpdated():
FrameProcessor.h:

Code: Select all

#include <QtCore/QDebug> #include "src/core/VideoStream.h" class VlcFrameProcessor : public VlcVideoStream { public: VlcFrameProcessor(QObject *parent); virtual void frameUpdated(); };
FrameProcessor.cpp:

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; }
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); //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); }
I expected I could receive some frame data in VlcFrameProcessor::frameUpdated(). INDEED, it can! It can receive width, height & frameBuffer.
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!

chubinou
Developer
Developer
Posts: 521
Joined: 23 Jul 2015 15:19

Re: [vlc-qt] Get wrong frame buffer

Postby chubinou » 02 Nov 2021 10:26

Hi, I'm not familiar with this particular wrapper, but as I understand it:

* you redirect the video to your VlcFrameProcessor, so the widget is not feed anymore (hence the green screen)
* you don't do anything with your video in you VlcFrameProcessor, you need to draw it manually.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 19 guests