我正在使用GStreamer 1.10.4爲了在Java應用程序中執行原始視頻流播放。GStreamer - 無法鏈接Decodebin元素(NOFORMAT)
這本我用我的Java應用程序外,視頻播放的命令:它工作正常
gst-launch-1.0 -v udpsrc multicast-group=239.192.2.1 auto-multicast=true port="5000" caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, sampling=(string)YCbCr-4:2:2, depth=(string)8, width=(string)1920, height=(string)1080, colorimetry=(string)BT709-2, payload=(int)96, a-framerate=(string)20" ! rtpvrawdepay ! decodebin ! videobox top=90 bottom=90 ! autovideosink sync=false
現在,我需要實現這個管道在我的Java應用程序。所以我使用:
- 的JNA-4.4.0.jar
- 的GST1-Java的核心0.9-161201.jar GStreamer的Java包裝
- 的SimpleVideoComponent.java類,GStreamer中的一部分-java,爲了嵌入視頻宿在一個JFrame UI對象
我能夠構建簡單的管道中的Java(如videotestsrc!autovideosink)被正確地顯示在我的UI。
但是,當我構建我的原始流式解碼管道時,事情會變得更加困難,如上面的命令行中所述。
提醒:udpsrc! rtpvrawdepay!解碼器! videobox! autovideosink
的問題是,我不能decodebin的SRC0焊盤連接到videobox的接收墊:我得到一個NOFORMAT錯誤
這裏是我使用的管道建設相關的代碼:
String[] gstreamerArgs = new String[1];
gstreamerArgs[0] = "-v";
Gst.init("Video", gstreamerArgs);
mPipeline = new Pipeline("pipeline");
// Create elements =================================================================
elmt_udpsrc = ElementFactory.make("udpsrc", "udpsrc");
elmt_udpsrc.set("multicast-group", "239.192.2.1");
elmt_udpsrc.set("auto-multicast", true);
elmt_udpsrc.set("port", 5000);
Caps caps = new Caps("application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, sampling=(string)YCbCr-4:2:2, depth=(string)8, width=(string)1920, height=(string)1080, colorimetry=(string)BT709-2, payload=(int)96, a-framerate=(string)20");
elmt_udpsrc.set("caps", caps);
elmt_rtpvrawdepay = ElementFactory.make("rtpvrawdepay", "rtpvrawdepay");
elmt_decodebin = ElementFactory.make("decodebin", "decodebin"); // has a "Sometimes" pad
elmt_decodebin.connect(new PAD_ADDED() {
@Override
public void padAdded(final Element element, final Pad pad) {
if (pad.isLinked()) {
return;
}
// Prints "Linking Decodebin pad : src_0 to sink"
System.out.println("VideoHandlerUI - Linking Decodebin pad : " + pad.getName() + " to " + elmt_autovideosink.getStaticPad("sink").getName());
PadLinkReturn retour = pad.link(elmt_videobox.getStaticPad("sink")); // NOFORMAT error !
inspect(mPipeline);
mPipeline.play();
}
});
elmt_videobox = ElementFactory.make("videobox", "videobox");
elmt_autovideosink = videoUIComponent.getElement();
elmt_autovideosink.set("sync", false);
// Build Pipeline =================================================================
mPipeline.addMany(elmt_udpsrc, elmt_rtpvrawdepay, elmt_decodebin, elmt_videobox, elmt_autovideosink);
bStatus1 = Element.linkMany(elmt_udpsrc, elmt_rtpvrawdepay, elmt_decodebin); // TRUE
bStatus2 = Element.linkMany(elmt_videobox, elmt_autovideosink); // TRUE
這裏是在padAdded回調的檢查(管道)函數的輸出,連接嘗試後:
GstVideoComponent
Sink pad: sink connected to peer parent=BaseTransform: [videobox]/Pad: [src]
videobox
Sink pad: sink DISCONNECTED
Src pad: src connected to peer parent=AppSink: [GstVideoComponent]/Pad: [sink]
decodebin
Sink pad: sink connected to peer parent=Element: [rtpvrawdepay]/Pad: [src]
Sink pad: src_0 DISCONNECTED
rtpvrawdepay
Sink pad: sink connected to peer parent=BaseSrc: [udpsrc]/Pad: [src]
Src pad: src connected to peer parent=DecodeBin: [decodebin]/GhostPad: [sink]
udpsrc
Src pad: src connected to peer parent=Element: [rtpvrawdepay]/Pad: [sink]
我正在編程這條管道的方式非常接近other examples I found on the web。我不明白爲什麼我得到這兩個元素之間的NOFORMAT誤差爲同一流水線工作正常兩種:
- 在命令行模式下
- 在Java中傳遞整個管道串GStreamer的時候綁定(但這不是一個合適的解決方案,因爲我需要控制管道元素)
我也嘗試將decodebin直接鏈接到videosink元素(不使用videobox),但我得到相同的結果。
任何關於我可能已經忘記在我的代碼中的任何棘手的事情的想法?我怎麼能更深入地看到元件墊會發生什麼?