Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rendering Issue in Video with Transparency Using QGraphicsVideoItem
Forum Updated to NodeBB v4.3 + New Features

Rendering Issue in Video with Transparency Using QGraphicsVideoItem

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 2 Posters 954 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mervyn
    wrote on last edited by
    #1

    Here is the rendering issue of an .avi video with transparency being rendered in a QGraphicsVideoItem.
    4dec2169-6153-4769-a477-1d557f6697df-image.png

    It should have been like this instead (played in VLC):
    682d4dd8-a4b0-48f5-a93f-0f16fcc8eb78-image.png

    The codec I'm using is K-Lite Mega Pack and the videos are rendering fine in other software like VLC and Adobe Premiere Pro. And the program is being developed in Visual Studio (compiled in msvc2017) using QT plugin.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What do you get if you use a QVideoWidget ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mervyn
        wrote on last edited by
        #3

        I do get the correct result like in VLC. But unfortunately, my project requires to use a coordinate system and functionalities to drag the video object around. I am trying out other video format with alpha channel support as well and will further update this post.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I did get that. The test with QVideoWidget is to determine whether there's an issue also there or only with QGraphicsVideoItem.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          0
          • SGaistS SGaist

            I did get that. The test with QVideoWidget is to determine whether there's an issue also there or only with QGraphicsVideoItem.

            M Offline
            M Offline
            Mervyn
            wrote on last edited by
            #5

            @SGaist Just to clarify things a bit. The correct result was from the QVideoWidget.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Mervyn
              wrote on last edited by
              #6

              I have tested out other formats like .mov and .flv but no luck there either. So what seems to be the issue?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Maybe a bug in the QGraphicsVideoItem implementation.

                Are you using the QGraphicsView only to make the video movable ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Mervyn
                  wrote on last edited by
                  #8

                  Yes, I am using the original QGraphicsView but with a custom QGraphicsScene. Further digging points towards blending issue. I suspect maybe something to do with glsl shader that is used for rendering, but I'm not sure.

                  The artifacts in the .avi video as shown in the previous example has premultipled alpha. When I use a new .avi video with straight alpha instead the issue is improved, but not entirely gone (black side bars gone, and less artifacts).

                  For the new examples:

                  Slight discoloration in the waveform.

                  0da6cc7d-2143-4d30-9f2a-ad22a83d8a59-image.png

                  1d7128c7-811f-43d4-8002-89ebfa351422-image.png

                  Other notable issue includes black outlines where there shouldn't be any.

                  747fd1c2-8bee-471b-969b-af4dc3b9777c-image.png

                  78c27501-6b76-4ad3-b8b8-7ab4d507ab27-image.png

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    What does your custom scene do ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    M 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      What does your custom scene do ?

                      M Offline
                      M Offline
                      Mervyn
                      wrote on last edited by
                      #10

                      @SGaist Just drag and drop support for the QGraphicsVideoItems

                      protected:
                      
                      	QString mimeType();
                      
                      	void mousePressEvent(QGraphicsSceneMouseEvent* event);
                      	void dragEnterEvent(QGraphicsSceneDragDropEvent* event);
                      	void dragLeaveEvent(QGraphicsSceneDragDropEvent* event);
                      	void dropEvent(QGraphicsSceneDragDropEvent* event);
                      	void dragMoveEvent(QGraphicsSceneDragDropEvent* event);
                      
                      	void keyPressEvent(QKeyEvent* event);
                      
                      
                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Isn't setting the QGraphicsItem::ItemIsMovable enough for that ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        M 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          Isn't setting the QGraphicsItem::ItemIsMovable enough for that ?

                          M Offline
                          M Offline
                          Mervyn
                          wrote on last edited by
                          #12

                          @SGaist Sorry, I meant drag and drop from a QTreeWidget into QGraphicsScene. Hence, I need to add additional functionalities for the drag and drop event.

                          On a side note, I am able to reproduce the same artifacts with a minimal reproducible example. So, I would assume the issue doesn't stem from my code. The following is the code for the minimal reproducible example. The first image in my initial post is the result.

                          #pragma once
                          
                          #include "ui_QtGuiApplication1.h"
                          #include <QtCore>
                          #include <QDebug>
                          #include <QGraphicsVideoItem>
                          #include <QGraphicsView>
                          #include <QGraphicsScene>
                          #include <QMediaPlayer>
                          #include <QUrl>
                          #include <QString>
                          
                          
                          class QtGuiApplication1 : public QMainWindow
                          {
                          	Q_OBJECT
                          
                          public:
                          	QtGuiApplication1(QWidget *parent = Q_NULLPTR);
                          
                          private:
                          	Ui::QtGuiApplication1Class ui;
                          };
                          
                          
                          #include "QtGuiApplication1.h"
                          
                          QtGuiApplication1::QtGuiApplication1(QWidget *parent): QMainWindow(parent)
                          {
                          	ui.setupUi(this);
                          	
                          	QGraphicsView* view = new QGraphicsView(ui.widget);
                          	QGraphicsScene* scene = new QGraphicsScene();
                          	QGraphicsVideoItem* video = new QGraphicsVideoItem();
                          	QMediaPlayer* player = new QMediaPlayer();
                          	QUrl path = QUrl::fromLocalFile("FILE HERE");
                          	QVBoxLayout* layout = new QVBoxLayout();
                          
                          	layout->addWidget(view);
                          	ui.widget->setLayout(layout);
                          	video->setFlags(QGraphicsVideoItem::ItemIsMovable | QGraphicsVideoItem::ItemIsFocusable | QGraphicsVideoItem::ItemIsSelectable);
                          	video->setPos(100, 100);
                                  view->setScene(scene);
                          	player->setMedia(path);
                          	player->setVideoOutput(video);
                          	scene->addItem(video);
                          	player->play();
                          	view->show();
                          }
                          
                          <?xml version="1.0" encoding="UTF-8"?>
                          <ui version="4.0">
                           <class>QtGuiApplication1Class</class>
                           <widget class="QMainWindow" name="QtGuiApplication1Class">
                            <property name="geometry">
                             <rect>
                              <x>0</x>
                              <y>0</y>
                              <width>844</width>
                              <height>639</height>
                             </rect>
                            </property>
                            <property name="windowTitle">
                             <string>QtGuiApplication1</string>
                            </property>
                            <widget class="QWidget" name="centralWidget">
                             <property name="sizePolicy">
                              <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
                               <horstretch>0</horstretch>
                               <verstretch>0</verstretch>
                              </sizepolicy>
                             </property>
                             <property name="minimumSize">
                              <size>
                               <width>0</width>
                               <height>0</height>
                              </size>
                             </property>
                             <property name="autoFillBackground">
                              <bool>true</bool>
                             </property>
                             <layout class="QVBoxLayout" name="verticalLayout">
                              <item>
                               <widget class="QWidget" name="widget" native="true">
                                <property name="sizePolicy">
                                 <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
                                  <horstretch>0</horstretch>
                                  <verstretch>0</verstretch>
                                 </sizepolicy>
                                </property>
                                <property name="minimumSize">
                                 <size>
                                  <width>0</width>
                                  <height>400</height>
                                 </size>
                                </property>
                               </widget>
                              </item>
                             </layout>
                            </widget>
                           </widget>
                           <layoutdefault spacing="6" margin="11"/>
                           <resources>
                            <include location="QtGuiApplication1.qrc"/>
                           </resources>
                           <connections/>
                          </ui>
                          
                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved