简体   繁体   English

无法在gstreamer中向管道添加过滤器

[英]Failure adding filter to pipeline in gstreamer

I'm trying to do the exercise at the end of the Basic GStreamer tutorial here: Basic Tutorial 2 . 我正在尝试在Basic GStreamer教程结束时进行练习: 基础教程2 The exercise is merely to add a filter to a video. 练习仅仅是为视频添加过滤器。 The exercise says to simply add the "vertigoTV" effect, so I did that. 练习说只是添加“vertigoTV”效果,所以我这样做了。

Here are the relevant parts to my attempt: 以下是我尝试的相关部分:

    #include <gst/gst.h>

int main(int argc, char *argv[]) {
  GstElement *pipeline, *source, *filter, *convert, *sink;
  GstBus *bus;
  GstMessage *msg;
  GstStateChangeReturn ret;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  /* Create the elements */
  source = gst_element_factory_make ("videotestsrc", "source");
  filter = gst_element_factory_make ("vertigotv", "filter");
  sink = gst_element_factory_make ("autovideosink", "sink");

  /* Create the empty pipeline */
  pipeline = gst_pipeline_new ("test-pipeline");

  if (!pipeline || !source || !filter || !sink) {
    g_printerr ("Not all elements could be created.\n");
    return -1;
  }

  /* Build the pipeline */
  gst_bin_add_many (GST_BIN (pipeline), source, filter, sink, NULL);
  if (gst_element_link_many (source, filter, sink, NULL) != TRUE) {
    g_printerr ("Could not link all elements.\n");
    gst_object_unref (pipeline);
    return -1;
  }

  /* Modify the source's properties */
  g_object_set (source, "pattern", 0, NULL);

  /* Start playing */
  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
  if (ret == GST_STATE_CHANGE_FAILURE) {
    g_printerr ("Unable to set the pipeline to the playing state.\n");
    gst_object_unref (pipeline);
    return -1;
  }

  /* Wait until error or EOS */
  bus = gst_element_get_bus (pipeline);
  msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

  /* Parse message */
  if (msg != NULL) {
    GError *err;
    gchar *debug_info;

    switch (GST_MESSAGE_TYPE (msg)) {
      case GST_MESSAGE_ERROR:
        gst_message_parse_error (msg, &err, &debug_info);
        g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);
        g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");
        g_clear_error (&err);
        g_free (debug_info);
        break;
      case GST_MESSAGE_EOS:
        g_print ("End-Of-Stream reached.\n");
        break;
      default:
        /* We should not reach here because we only asked for ERRORs and EOS */
        g_printerr ("Unexpected message received.\n");
        break;
    }
    gst_message_unref (msg);
  }

  /* Free resources */
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;
}

However, the return value is a GST_STATE_CHANGE_FAILURE. 但是,返回值是GST_STATE_CHANGE_FAILURE。 Any idea why? 知道为什么吗?

Thanks so much! 非常感谢!

过滤后添加视频转换:

gst-launch-1.0 videotestsrc ! vertigotv ! videoconvert ! autovideosink

This will definitely work, I have tried and got it working. 这肯定会奏效,我已经尝试过并且正常运行。

Please try some other steps or add the exact error you got. 请尝试其他一些步骤或添加您得到的确切错误。 You may also want to post the complete code. 您可能还想发布完整的代码。

PS - wanted to add this as comment but fall short of 2 rep PS - 希望将此添加为评论,但未达到2个代表

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

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