Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.8.3, 6.9.0
-
None
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);