Java GStreamer-无法链接Decodebin元素(NOFORMAT)
我使用GStreamer 1.10.4在Java应用程序中执行原始视频流播放 这是我在Java应用程序外用于视频播放的命令:它工作正常Java GStreamer-无法链接Decodebin元素(NOFORMAT),java,video,gstreamer,pipeline,Java,Video,Gstreamer,Pipeline,我使用GStreamer 1.10.4在Java应用程序中执行原始视频流播放 这是我在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,
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-core-0.9-161201.jar GStreamer java包装器
- SimpleVideoComponent.java类是gstreamer java的一部分,用于将视频接收器嵌入JFrame UI对象中
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回调中inspect(pipeline)函数的输出:
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]
我编程这个管道的方式非常接近。我不明白为什么这两个元素之间会出现NOFORMAT错误,因为同一条管道可以同时正常工作:
- 在命令行模式下
- 在java中,将整个管道字符串传递给GStreamer绑定时(但这不是合适的解决方案,因为我需要控制管道元素)
你知道我可能在代码中忘记了什么棘手的事情吗?我怎样才能更深入地了解谈判中发生了什么?我发现了问题所在。appsink功能与decodebin的功能不匹配。 我通过移除decodebin元素并用videoconvert元素替换它解决了这个问题,视频播放工作正常