Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-137174

Possible improvement on how QGraphicsVideoItem handles rotated video

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.8.3, 6.9.0
    • None
    • Windows

    Description

      The issue can be illustrated by playing the attached video with our videographicsitem example:
      https://doc.qt.io/qt-6/qtmultimedia-videographicsitem-example.html

      The video is 1280x720 (landscape) but rotated by -90 degree, which makes it essentially in portrait mode. QGraphicsVideoItem can only recognize it partially. The initial frame is in portrait mode, but only the landscape part can be played. You can see obviously tearing of the video frame:

      A partially working fix is to manually set the videoItem size and corresponding sceneRect:

          m_transposeConnection = connect(m_videoItem->videoSink(), &QVideoSink::videoSizeChanged, [&]() {
              QSize size = m_videoItem->videoSink()->videoSize();
              size.transpose();
              m_videoItem->setSize(size);
              m_view->setSceneRect(m_videoItem->boundingRect());
              m_view->fitInView(m_videoItem->boundingRect(), Qt::KeepAspectRatio);
          });
      

      in, e.g., constructor of VideoPlayer after QGraphicsView is created and before QVideoGraphicsItem is added into scene.

      It works in case of VideoPlayer is in landscape modem i.e. the widget height is less than its width. But in case of portrait mode, the result still looks ugly, that too much space is wasted:

      So the original reporter suggests such modification in

      void QGraphicsVideoItemPrivate::_q_present(const QVideoFrame &frame) 
      

      That is:

      //was const QSize &size = frame.surfaceFormat().viewport().size();
      #include <private/qmultimediautils_p.h>
      const QSize size = qRotatedFramePresentationSize(frame); 
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtmultimediateam Qt Multimedia Team
            luqiaochen Luqiao Chen
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes