<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QGraphicsVideoItem not working with GStreamer media source]]></title><description><![CDATA[<p dir="auto">Good afternoon,</p>
<p dir="auto">I'm having some trouble using a QGraphicsVideoItem with a GStreamer pipeline as source.</p>
<p dir="auto">I'm trying to show the video on a QMdiSubWindow, and using a QVideoWidget it works, but i need to draw some boxes on top on the video and followed this <a href="https://forum.qt.io/topic/1024/paint-over-qvideowidget/9">forum topic</a>.</p>
<p dir="auto">Using a local file instead of the GStreamer pipeline shows the video with no problems.</p>
<p dir="auto">To avoid an XY problem, TLDR: trying to draw rectangles on top of a video inside of a QMdiSubWindow whose source is a GStreamer pipeline.</p>
<p dir="auto">Here's the code for my subclassed subwindow</p>
<pre><code>videoSubWindow::videoSubWindow(int shmID, int width, int height, QWidget* parent): QMdiSubWindow(), shmID(shmID), player(nullptr), videoWidget(nullptr) {
    std::cerr &lt;&lt; __func__ &lt;&lt; "\n";

    std::string playerLaunch = "gst-pipeline: shmsrc socket-path=/tmp/shm" + std::to_string(shmID) +
        " ! video/x-raw, format=(string)I420, width=(int)" + std::to_string(width) + 
        ", height=(int)" + std::to_string(height) + ", framerate=(fraction)30/1 ! queue ! xvimagesink name=qtvideosink";

    videoWidget = new roiVideoWidget(this);
    scene = new QGraphicsScene(videoWidget);
    item = new QGraphicsVideoItem;
    videoWidget-&gt;setScene(scene);
    scene-&gt;addItem(item);
    player = new QMediaPlayer;
    player-&gt;setVideoOutput(item);
    player-&gt;setMedia(QUrl(playerLaunch.c_str()));
    //player-&gt;setMedia(QUrl::fromLocalFile("testvideo.mp4"));
    
    setWidget(videoWidget);
        
    setAttribute(Qt::WA_DeleteOnClose);
}
</code></pre>
<p dir="auto">Thanks in advance for any help.</p>
<p dir="auto">PS: Using Qt 5.12 on Ubuntu 20.04 and GCC 10</p>
]]></description><link>https://forum.qt.io/topic/142250/qgraphicsvideoitem-not-working-with-gstreamer-media-source</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 07:53:20 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/142250.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 17 Jan 2023 15:09:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QGraphicsVideoItem not working with GStreamer media source on Tue, 17 Jan 2023 21:14:18 GMT]]></title><description><![CDATA[<p dir="auto">Nevermind, i fixed it, just had to update to Qt5.15 to get access to the video surface of the QGraphicsVideoItem and update the videosink to autovideosink.<br />
Here is my solution's code</p>
<pre><code>videoSubWindow::videoSubWindow(int shmID, int width, int height, QWidget* parent): QMdiSubWindow(), shmID(shmID), player(nullptr), videoWidget(nullptr) {
    std::cerr &lt;&lt; __func__ &lt;&lt; "\n";

    std::string playerLaunch = "gst-pipeline: shmsrc socket-path=/tmp/shm" + std::to_string(shmID) +
        " ! video/x-raw, format=(string)I420, width=(int)" + std::to_string(width) + 
        ", height=(int)" + std::to_string(height) + ", framerate=(fraction)30/1 ! queue ! videoconvert ! autovideosink";


    scene = new QGraphicsScene(videoWidget);
    videoWidget = new roiVideoWidget(scene, this);
    videoItem = new QGraphicsVideoItem;
    scene-&gt;addItem(videoItem);
    player = new QMediaPlayer;
    player-&gt;setVideoOutput(videoItem-&gt;videoSurface());
    player-&gt;setMedia(QUrl(playerLaunch.c_str()));
    player-&gt;play();

    setWidget(videoWidget);

    setAttribute(Qt::WA_DeleteOnClose);
}
</code></pre>
]]></description><link>https://forum.qt.io/post/744166</link><guid isPermaLink="true">https://forum.qt.io/post/744166</guid><dc:creator><![CDATA[Xavier Bento]]></dc:creator><pubDate>Tue, 17 Jan 2023 21:14:18 GMT</pubDate></item></channel></rss>