astarakastara
astarakastara

Reputation: 545

Gstreamer Video Overlay Invalid Cast on QWidget , Windows 10

Problem is I couldn't stream camera or any video in QWidget. I can do it without Qt but I need to do in QWidget. The syntax is fine. QWidget appears but nothing in it. I used GstElement* for source and sink.

data.source = gst_element_factory_make("autovideosrc", "source");
data.sink = gst_element_factory_make("autovideosink", "sink");

In Command Line it works fine when I write
" gst-launch-1.0 autovideosrc ! autovideosink "
However, it doesn't work on code.

QApplication::sync(); gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(GST_ELEMENT(data.sink)),guintptr(ui.widget->winId()));


It gives this error:

GLib-GObject-WARNING **: invalid cast from 'GstAutoVideoSink' to 'GstVideoOverlay'

** (QtGuiApplication2.exe:6188): CRITICAL **: gst_video_overlay_set_window_handle: assertion 'GST_IS_VIDEO_OVERLAY (overlay)' failed

<<< This problem is at almost everywhere but still there is no clear solution both in stackoverflow, qtcentre and gstreamer developer forum. I know someone would have solved this already but please reply to forums...>>>

How can I solve this problem? Thank you for your attention.

Upvotes: 0

Views: 2694

Answers (1)

Florian Zwoch
Florian Zwoch

Reputation: 7373

autovideosink does not expose the GstVideoOverlay interface. Because it is not a real renderer but merely an auto-plug helper. Sometime after you start the pipeline it decides to plug in an actual renderer.

You should add a bus sync handler to check for the prepare overlay message and then do the video overlay calls. The documentation shows the basic idea with examples:

https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/GstVideoOverlay.html

Upvotes: 3

Related Questions