【问题标题】:Gstreamer with visual C++ express 2010 - tutorial 1Gstreamer 与 Visual C++ express 2010 - 教程 1
【发布时间】:2021-10-17 00:07:06
【问题描述】:

我是Gstreamer的新手,在编译Gstreamer的教程1时遇到问题。我正在使用带有 Visual c++ express 2010 的 Windows 7 64 位和 Gstreamer SDK 2012.11 32 位 (downloaded from here)。 这是代码:

#include "stdafx.h"
#include <gst/gst.h>

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

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

  /* Build the pipeline */
  pipeline = gst_parse_launch ("playbin2 uri=file://E:/test_1.MOV", NULL);

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

第一个错误:

error C2664: 'gst_bus_timed_pop_filtered' : cannot convert parameter 3 from 'int' to 'GstMessageType'

所以我刚刚从代码中删除了 GST_MESSAGE_ERROR。所以现在是:

msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_EOS);

我在 Ubuntu 上遇到了同样的问题。但在那之后,在 Ubuntu 中,我可以播放视频。

第二个错误: 但是对于 Windows,编译很好,但是当我尝试运行它时,我有那些错误:

GStreamer-CRITICAL **: gst_element_set_state: assertion 'GST_IS_ELEMENT <element>' failed
GStreamer-CRITICAL **: gst_element_get_bus: assertion 'GST_IS_ELEMENT <element>' failed
GStreamer-CRITICAL **: gst_bus_timed_pop_filtered: assertion 'GST_IS_BUS <bus>' failed
GStreamer-CRITICAL **: gst_object_unref: assertion 'object=!NULL' failed
GStreamer-CRITICAL **: gst_element_set_state: assertion 'GST_IS_ELEMENT <element>' failed
GStreamer-CRITICAL **: gst_object_unref: assertion 'object=!NULL' failed

我真的不明白为什么它适用于 ubuntu 而不适用于 Windows。我真的不知道如何解决这个问题。 你能帮我吗?

问候,

【问题讨论】:

    标签: visual-c++ gstreamer


    【解决方案1】:

    l第一个错误

    可能代码被编译为 C++,这在枚举类型转换方面更加严格。尝试更换: GST_MESSAGE_ERROR | GST_MESSAGE_EOS(GstMessageType)(GST_MESSAGE_ERROR | GST_MESSAGE_EOS)

    第二个错误

    很有可能,那行:

    pipeline = gst_parse_launch ("playbin2 uri=file://E:/test_1.MOV", NULL);
    

    返回 NULL,其余的错误都是由此产生的。为什么它可以返回NULL?有很多原因。也许您还没有安装带有“playbin2”的插件?试试这个:

    • 将指向GError 结构的指针作为第二个参数传递给gst_parse_launch(它有一个message 字段可以给你一些提示)
    • 在运行程序时将--gst-debug-level=4 或更高的参数作为命令行参数传递。你会在控制台输出看到很多信息,失败的原因就在那里。

    【讨论】:

    • 你应该在这里使用 static_cast() 而不是 C 风格的转换。
    【解决方案2】:

    我认为您使用的是 gstreamer 1.0,如果我没有错,请尝试使用

    “playbin”而不是“palybin2”

    “playbin2”从 gstreamer 1.0 重命名为“playbin”

    【讨论】:

      【解决方案3】:

      第二个错误:

      我想为 Ubuntu 16.04 LTS 用户解释这一点。

      要尝试来自 GStreamer tutorials sections 的示例,您应该从这些存储库的源代码编译和安装:

      gstreamer
      gst-plugins-base
      gst-plugins-good
      

      原因是用于示例的版本与我使用 apt 安装的版本不匹配(缺少playbin)。

      在从源代码编译之前,您还需要依赖项来构建 vorbisvpxsouphttpsrc 插件(它们是提到的存储库的一部分)。您可以通过运行来安装它们:

      apt install libvorbis-dev libsoup2.4-dev libvpx-dev

      要检查提到的插件是否包含在存储库构建中,请参阅./configure 输出。如果不是,您的系统上可能仍然缺少一些依赖项。输出会告诉你缺少什么。

      之后,您应该成功编译并运行示例(您应该会看到视频播放)。

      解决 GStreamer 初始安装问题的一般流程是(如已接受的答案中所述)使用 --gst-debug-level=4,找出缺少的插件并安装它们。

      【讨论】:

        【解决方案4】:

        对于错误 1 如果您使用 C++ 编译 利用: gst_bus_timed_pop_filtered(bus, GST_CLOCK_TIME_NONE, static_cast&lt;GstMessageType&gt;(GST_MESSAGE_ERROR | GST_MESSAGE_EOS)); 代替: gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-06-30
          • 2011-07-03
          • 1970-01-01
          相关资源
          最近更新 更多