【问题标题】:GStreamer - Cannot link Decodebin element (NOFORMAT)GStreamer - 无法链接 Decodebin 元素 (NOFORMAT)
【发布时间】:2017-06-17 17:41:38
【问题描述】:

我正在使用 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, 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 对象中

我能够用 Java 构建简单的管道(如 videotestsrc !autovideosink),这些管道可以正确显示在我的 UI 中。

但是,当我按照上面的命令行所述构建原始流解码管道时,事情变得更加困难。

提醒:udpsrc! rtpvrawdepay!解码器!视频盒!自动视频接收器

问题是我无法将 decodebin 的 src0 pad 链接到 videobox 的 sink pad:我收到 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 回调中的 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]

我对此管道的编程方式非常接近other examples I found on the web。我不明白为什么在这两个元素之间会出现 NOFORMAT 错误,因为同一管道都可以正常工作:

  • 在命令行模式下
  • 在 java 中将整个管道字符串传递给 GStreamer 绑定时(但这不是一个合适的解决方案,因为我需要控制管道元素)

我还尝试将 decodebin 直接链接到 videosink 元素(不使用 videobox),但我得到了相同的结果。

对我在代码中可能忘记的任何棘手的事情有任何想法吗?我怎样才能更深入地了解元素垫协商中会发生什么?

【问题讨论】:

    标签: java video gstreamer pipeline


    【解决方案1】:

    我找到了问题所在。 appsink 功能与 decodebin 的功能不匹配。 我通过删除 decodebin 元素并将其替换为 videoconvert 元素解决了这个问题,并且视频播放正常。

    【讨论】:

      猜你喜欢
      • 2018-09-13
      • 1970-01-01
      • 1970-01-01
      • 2012-09-20
      • 1970-01-01
      • 1970-01-01
      • 2017-05-24
      • 1970-01-01
      • 2017-09-14
      相关资源
      最近更新 更多