Solved Change video brightness in QGraphicsView not working!
-
Hi Team,
I am trying to render the video using the GraphicsView display widget and also used QGraphicsView class, but my settings for brightness and saturation etc. are not getting rendered! I have used update() for every object now, just pasting the code, I am strucggeling with:
m_dragVid->setBrightness(66); m_dragVid->setSaturation(77); // nothing below works! scene->update(); viditem->update(); m_dragVid->update(); ui->graphicsView->update(); ui->graphicsView->updateSceneRect(m_dragVid->geometry());
Please help me!
Best,
Vicky -
Hi @vicky-vigia,
I guess your "video" is a
QVideoWidget
?! Then check out this: https://bugreports.qt.io/browse/QTBUG-35299 and have a look at this example (https://doc.qt.io/qt-5/qtmultimedia-multimediawidgets-player-example.html)Or what kind of type is
m_dragVid
?
Is there a reason why you are using aQGraphicsView
for your video? -
Thank you for your reply.
Yes, my video is a QVideoWidget (m_dragVid).
The reason I am using QGraphicsView is that I want to render multiple video objects on my layout. And each can be moved, resized, basically interacted via mouse and UI controls separately. I tried doing the same using QVideoWidgets but wasn't able to, maybe I was doing it wrong!Best,
Vicky -
What about a
QDockWidget
with aQVideoWidget
inside for each video? You can move them around on your parent (docking area) window and resize / edit all of them separately. -
Okay, I will try this and come back here!
Thanks for your guidance!
-
Hi Team,
I am back! The QDockWidget(QVideoWidget) is working now, thanks! But, not sure, if this is what I want. As I am unable to resize it, while the video is running, using the UI controls in my main window.
I want to set the position of the video, which is in my dockwidget, using a text field to let's say providing X, Y location. The code I tried is:
void MainWindow::on_txtLocationX_textChanged(const QString &arg1) { int ypos = ui->txtLocationY->text().toInt(); ui->dockVid->setGeometry(10, ypos, 200, 200); }
And similarly for rotation. Cause now, if I do the following, it crashes!
m_dragVid->rotateVideo(10);
Thanks again for your help!
-
@vicky-vigia said in Change video brightness in QGraphicsView not working!:
As I am unable to resize it, while the video is running, using the UI controls in my main window
Resizing the DockWidget-Window as well as the
QVideoWidget
inside the dockWidget should work with your UI-controls.@vicky-vigia said in Change video brightness in QGraphicsView not working!:
m_dragVid->rotateVideo(10);
In this example (https://doc.qt.io/archives/qt-5.6/qtmultimedia-multimediawidgets-videographicsitem-videoplayer-cpp.html) the video is a
QGraphicsVideoItem
type. Did you use the code from this example? -
Thanks for the reply.
I tried resizing the dock + video, it resized but crashed, it seems I am messing up with the position and H and W params, will try more and I think I can fix that!I have followed the MediaPlayer example. What is the name of the example, you have referred to? I will do a lookup in my QT editor.
Best,
Vicky -
The code file from my last reply is from this Qt example: https://doc.qt.io/archives/qt-5.6/qtmultimedia-multimediawidgets-videographicsitem-example.html
@vicky-vigia said in Change video brightness in QGraphicsView not working!:
I tried resizing the dock + video, it resized but crashed, it seems I am messing up with the position and H and W params, will try more and I think I can fix that!
Depends on what you need and what kind of video do you have. If you have access to all single frames of each video, you could also show the frames as
QLabel
, but then there is nomyVid->setSaturation()
:) -
Thank you for your reply. I will check the example and learn more from it.
Regarding rendering frames as QLabel objects, I want to know more. As I am planning to use FFMPEG and do some advance video-frames manipulations like these and these and some more.
Any help, suggestions, pointers to the right documentation and examples, is much appreciated!
-
@vicky-vigia said in Change video brightness in QGraphicsView not working!:
Regarding rendering frames as QLabel objects, I want to know more
You can use a
QLabel
as placeholder to display images / video frames.@vicky-vigia said in Change video brightness in QGraphicsView not working!:
As I am planning to use FFMPEG and do some advance video-frames manipulations
You can use FFMPEG for your manipulations and show the result in your Qt GUI.
Have a look here:
https://www.bogotobogo.com/Qt/Qt5_QProcess_QFileDialog_QTextEdit_FFmpeg.php
and here:
https://www.bogotobogo.com/Qt/Qt5_QWebView_FFmpeg_Converter_Media_Player.phpvoid Dialog::on_playInputButton_clicked() { QString program = "C:/FFmpeg/bin/ffplay"; QStringList arguments; QString input = ui->fromLineEdit->text(); arguments << input; mInputPlayProcess->start(program, arguments); }
You can set your arguments inside your GUI to convert / edit the video.
-
Alright, awesome, thanks!
Any related example for QLabel?- Vicky
-
Here's everything you need to know about
QLabel
(https://doc.qt.io/qt-5/qlabel.html)
setPicture
orsetPixmap
for single images / frames
(In one of my projects I use OpenCV to display video frames from webcam on a QLabel).