为了在GStreamer应用程序中执行原始视频流播放,我使用了Java1.10.4。
这是我在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应用程序中实现这个管道。所以我用:
我能够用Java构建简单的管道(比如视频测试to!)在我的UI中正确显示的自动视频链接。
然而,当我像上面的命令行所描述的那样构建我的原始流解码管道时,事情会变得更加困难。
提醒:udpsrc!拉德佩蒂!破译!视频盒!自动视频链接
问题是我无法将解码器的src0便携器链接到视频盒的接收器盘:我得到了一个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]我编写这个管道的方式非常接近我在网上找到的其他例子。我不明白为什么在这两个元素之间得到一个NOFORMAT错误,因为相同的管道工作得很好。
我还试图直接将解码链接链接到视频链接元素(不使用视频盒),但我得到的结果是相同的。
对于我在代码中可能忘记的任何棘手的事情,有什么想法吗?我怎样才能更深入地了解元素pads negociations中发生的事情呢?
发布于 2017-06-17 09:41:38
我发现了问题所在。App接收器功能与解码功能不匹配。我解决了这个问题,移除了解码元素,取而代之的是一个视频转换元素,视频回放就可以了。
https://stackoverflow.com/questions/44495476
复制相似问题