我是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/