使用 gstreamer

问题描述

我想使用 libgstreamer 构建一个简单的静态二进制文件。这是来源

#include <gst/gst.h>
#include <stdbool.h>
#include <stdio.h>

int
main (int argc,char *argv[])
{
  GstElement *pipeline;
  GstBus *bus;
  GstMessage *msg;

  bool video = true;


  if (video == true) {
  /* Initialize GStreamer */
  gst_init (&argc,&argv);

  /* Build the pipeline */
  GError *err = NULL;
  pipeline =
          gst_parse_launch ("filesrc location=/home/name/Downloads/train160.webm ! matroskademux ! vp8dec ! xvimagesink",&err);
  if (err != NULL) {
          printf("error: %s",err->message);
  }

  /* Start playing */
  gst_element_set_state (pipeline,GST_STATE_PLAYING);

  /* 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);

  /* Free resources */
  if (msg != NULL)
    gst_message_unref (msg);
  gst_object_unref (bus);
  //gst_element_set_state (pipeline,GST_STATE_NULL);
  //gst_object_unref (pipeline);
  }
  return 0;
}

我正在按照 gst-build repository 中的说明进行操作,并使用以下命令来配置构建。我正在处理 1.19.1 标签,提交 3804f23

meson --default-library=static -Dintrospection=disabled -Dgst-full-elements='filesrc;matroskademux;vp8dec;xvimagesink' builddir

在我使用 ninja 构建和安装 gstreamer 之后,我使用调用构建程序

gcc -static -g -o test_bin_static test_bin.c $(pkg-config --cflags gstreamer-1.0) $(pkg-config --libs gstreamer-1.0) -lpcre -lffi -ldl

我收到以下有关使用 dlopen 的警告,大概是在加载插件函数中。把libdl链接成静态的porgram感觉很奇怪,但我想有必要支持插件架构吗?但是,据我所知,由于我在静态存档中包含了我使用的所有插件,因此不会引起问题。

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libgmodule-2.0.a(gmodule.c.o): in function `g_module_open':
(.text+0x713): warning: Using 'dlopen' in statically linked applications requires at
runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libglib-2.0.a(gutils.c.o): in function `g_get_user_database_entry':
(.text+0x277): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: (.text+0xe0): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: (.text+0x11e): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

问题是,当我运行程序时,gstreamer 运行时声称缺少插件。有趣的是,我在安装后构建动态程序时遇到此错误,所以我认为问题可能出在我构建 gstreamer 的标志中。但是,我不确定如何解决这个问题

(test_bin_static:1093706): GStreamer-CRITICAL **: 12:00:26.577: gst_element_set_state: assertion 'GST_IS_ELEMENT (element)' Failed

(test_bin_static:1093706): GStreamer-CRITICAL **: 12:00:26.577: gst_element_get_bus:
assertion 'GST_IS_ELEMENT (element)' Failed

(test_bin_static:1093706): GStreamer-CRITICAL **: 12:00:26.577: gst_bus_timed_pop_filtered: assertion 'GST_IS_BUS (bus)' Failed

(test_bin_static:1093706): GStreamer-CRITICAL **: 12:00:26.577: gst_object_unref: assertion 'object != NULL' Failed
error: no element "filesrc"

更新:我检查了我构建的 gst-inspect 版本,但它没有显示我尝试使用的任何插件,所以问题肯定是构建,但我不知道如何解决它。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)