2016-09-16 81 views
2

我正在嘗試使用QML將gsrtreamer視頻集成到QT應用程序中。如何在QML VideoItem中包含gstreamer sink?

我已經開始與它使用一個遙遠的視頻的例子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"); 

這是equivaltent到:

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

這個作品,我得到我的視頻流和我的播放/暫停/ st op按鈕正常工作。

但視頻是在不同的窗口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是在本地Qt自今年5.5起)或者沒有答案

我的工作是否有錯誤?

有沒有其他方法可以做我想做的?

謝謝。

回答

2

這裏的問題是autovideosink沒有實現「GstVideoOverlay」。在你的管道中,你應該使用這個元素的「xvimagesink,ximagesink」或者直接使用「playbin」作爲接收元素,這個元素實現「GstVideoOverlay」接口。

這裏是一個使用「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。 *網址是您的視頻網址。因爲你會是「udp://192.168.1.1:3333」