visual-c++ - Gstreamer 与 Visual C++ express 2010 - 教程 1

标签 visual-c++ gstreamer

我是Gstreamer的新手,在编译Gstreamer的教程1时遇到了问题。我将 Windows 7 64 位与 Visual c++ express 2010 和 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。我真的不知道如何解决这个问题。
请问你能帮帮我吗 ?

问候,

最佳答案

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甚至在运行程序时作为命令行参数更高。你会在控制台输出看到很多信息,失败的原因就在那里。
  • 关于visual-c++ - Gstreamer 与 Visual C++ express 2010 - 教程 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14923306/

    相关文章:

    python - GStreamer Python 解码器,jpegenc 元素未链接

    gstreamer - GStreamer 中 0(零)帧速率意味着什么?

    python - 以编程方式并排合并两个视频

    c++ - 为什么 VS2012 无法识别 C++ 项目中的某些 C++11 关键字?

    visual-c++ - 如何在Windows中使用sys/time.h?

    c++ - Visual Studio 2008 中命令行参数的 2 字节表示

    c - 如何覆盖GstBin中的handle_message?

    c++ - GStreamer 失真取决于图像大小

    visual-c++ - 在VC++中使用OpenGL时警告LNK4098和LNK1123

    c++ - PostThreadMessage 到另一个进程