c++ - 如何在 QML VideoItem 中包含 gstreamer 接收器?

标签 c++ qt qml gstreamer qt5.5

我正在尝试使用 QML 将 gsrtreamer 视频集成到 QT 应用中。

我从例子 qmlplayer2 开始使用远程视频:

player->setUri(QLatin1Literal("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi"));

我已修改此示例以使用管道获取 udpsrc :

    m_pipeline = QGst::Pipeline::create();
    QGst::ElementPtr udp = QGst::ElementFactory::make(QLatin1Literal("udpsrc"));
    udp->setProperty("address", "192.168.1.1");
    udp->setProperty("port", 3333);
    QGst::ElementPtr decodage = QGst::ElementFactory::make("jpegdec");
    QGst::ElementPtr videosink = QGst::ElementFactory::make("autovideosink");

相当于:

gst-launch-1.0 udpsrc address=192.168.1.1 port=3333 ! jpegdec ! autovideosink

这很有效,我可以播放我的视频,我的播放/暂停/停止按钮可以正常工作。

但是视频在不同的窗口中Two separate windows

而我的 QML指定 VideoItem 在主窗口中:

Rectangle {
    id: window
    width: 600
    height: 300
    Column {
        width: 600
        height: 544
        y : 10;
        VideoItem {
            id: video
            y : 10;
            width: window.width
            height: 260
            surface: videoSurface1 //bound on the context from main()
        }
        // Other buttons

我找到的每个主题要么太旧(gstreamer 自今年 5.5 起就原生于 Qt 中)要么没有答案

我的工作有错误吗?

还有其他方法可以做我想做的事吗?

谢谢。

最佳答案

这里的问题是 autovideosink 没有实现“GstVideoOverlay”。在您的管道中,您应该使用“xvimagesink,ximagesink”元素之一作为接收器元素或直接使用“playbin”,该元素实现“GstVideoOverlay”接口(interface)。

这里是一个使用“playbin”的例子。请注意,此示例使用的是没有 QT 包装器的纯 Gstreamer。

GstElement *pipeline = gst_element_factory_make("playbin", "playbin");
/* Set the URI to play */
g_object_set(pipeline, "uri", url, NULL);
gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(pipeline), windowsID);

*windowsID 是您要在其中绘制视频输出的小部件 ID。 *url 是您的视频网址。因为你会是“udp://192.168.1.1:3333”

关于c++ - 如何在 QML VideoItem 中包含 gstreamer 接收器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39531771/

相关文章:

linux - 这个小黑盒子是什么,我该如何摆脱它?

c++ - 测试 QQuickView (QWindow) 在 Qt 5.0.x 中是否全屏

c++ - 将现有的(行、列)C++ 模型与 QtQuick(网格、 TableView )一起使用

c++ - 将锁定的 std::unique_lock 移交给新线程

c++ - 我的glsl着色器加载代码有什么问题吗?

c++ - 具有绝对梯度和分块梯度的 QSlider

python - 使用 python 中的 PyQt5 按下按钮时更改 QML 中的标签

c++ - 有没有办法列出所有共享内存对象的名称?

c++ - OR 逻辑运算符从 C++ 到 Fortran 的转换

qt-creator - Qt Creator 无法识别 Qt3D