简体   繁体   English

gstreamer 0.1中不兼容的焊盘链接错误

[英]Incompatible pad linking error in gstreamer 0.1

I am trying to pragmatically create the following chain with gstreamer-0.10. 我正在尝试使用gstreamer-0.10实用地创建以下链。

gst-launch filesrc location=<file>.mkv ! decodebin ! ffenc_mpeg4 bitrate=5000000 ! rtpmp4vpay mtu=1400 pt=96 ssrc=0 timestamp-offset=0 seqnum-offset=0 send-config=true ! udpsink host=127.0.0.1 port=5000

Here is the code: 这是代码:

#include <gst/gst.h>

int
main (int   argc,
      char *argv[])
{
  GstElement* pipeline;
  GstElement* source;
  GstElement* decodebin;
  GstElement* encoder;
  GstElement* rtp;
  GstElement* udpsink;

  /* init */
  gst_init (&argc, &argv);

  /* create pipeline */
  pipeline = gst_pipeline_new ("my-pipeline");

  /* create elements */
  source = gst_element_factory_make ("filesrc", "source");
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);

  decodebin = gst_element_factory_make ("decodebin", "decoder");

  encoder = gst_element_factory_make ("ffenc_mpeg4", "encoder");
  g_object_set (G_OBJECT (encoder), "bitrate", "5000000", NULL);

  rtp = gst_element_factory_make ("rtpmp4vpay", "rtp");
  g_object_set (G_OBJECT (rtp), "mtu", "1400", NULL);
  g_object_set (G_OBJECT (rtp), "pt", 96, NULL);
  g_object_set (G_OBJECT (rtp), "ssrc", "0", NULL);
  g_object_set (G_OBJECT (rtp), "timestamp-offset", "0", NULL);
  g_object_set (G_OBJECT (rtp), "seqnum-offset", 0, NULL);
  g_object_set (G_OBJECT (rtp), "send-config", true, NULL); 

  udpsink = gst_element_factory_make ("udpsink", "udp");
  g_object_set (G_OBJECT (udpsink), "host", "127.0.0.1", NULL);
  g_object_set (G_OBJECT (udpsink), "port", 5000, NULL);

//  /* must add elements to pipeline before linking them */
  gst_bin_add_many (GST_BIN (pipeline), source, decodebin, encoder, rtp, udpsink, NULL);

  /* link */
  if (!gst_element_link_many (source, decodebin, encoder, rtp, udpsink, NULL)) {
    g_warning ("Failed to link elements!");
  }

}

Although this matches the gst-launch chain exactly, I get the following error in gst_element_link_many call. 尽管这与gst-launch链完全匹配,但在gst_element_link_many调用中出现以下错误。

0:00:03.025847872 28265       0x611400 INFO      GST_PLUGIN_LOADING gstplugin.c:859:gst_plugin_load_file: plugin "/usr/lib64/gstreamer-0.10/libgstudp.so" loaded
0:00:03.025912744 28265       0x611400 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:374:gst_element_factory_create: creating element "udpsink" named "udp"
0:00:03.026163748 28265       0x611400 INFO        GST_ELEMENT_PADS gstelement.c:728:gst_element_add_pad:<GstBaseSink@0x82b9e0> adding pad 'sink'
0:00:04.824498407 28265       0x611400 INFO        GST_ELEMENT_PADS gstutils.c:1698:gst_element_link_pads_full: trying to link element source:(any) to element decoder:(any)
0:00:04.824604374 28265       0x611400 INFO                GST_PADS gstutils.c:1032:gst_pad_check_link: trying to link source:src and decoder:sink
0:00:04.824676367 28265       0x611400 INFO                GST_PADS gstutils.c:1596:prepare_link_maybe_ghosting: source and decoder in same bin, no need for ghost pads
0:00:04.824725877 28265       0x611400 INFO                GST_PADS gstpad.c:1978:gst_pad_link_prepare: trying to link source:src and decoder:sink
0:00:04.824786544 28265       0x611400 INFO                GST_PADS gstpad.c:2161:gst_pad_link_full: linked source:src and decoder:sink, successful
0:00:04.824863468 28265       0x611400 INFO        GST_ELEMENT_PADS gstutils.c:1698:gst_element_link_pads_full: trying to link element decoder:(any) to element encoder:(any)
0:00:04.824989178 28265       0x611400 INFO        GST_ELEMENT_PADS gstelement.c:972:gst_element_get_static_pad: no such pad 'src%d' in element "decoder"
0:00:04.825051308 28265       0x611400 INFO        GST_ELEMENT_PADS gstutils.c:1216:gst_element_get_compatible_pad:<decoder> Could not find a compatible pad to link to encoder:sink

What am I doing wrong? 我究竟做错了什么? Can't I use the decode bin like this programatically? 我不能像这样以编程方式使用解码箱吗?

bin文档,发现解码器的src并不总是pad,有时是pad。通过当前日志可以看到相同的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM