带有Visual C ++ Express 2010的Gstreamer-教程1 [英] Gstreamer with visual C++ express 2010 - tutorial 1

查看:118
本文介绍了带有Visual C ++ Express 2010的Gstreamer-教程1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Gstreamer的新手,在编译Gstreamer的教程1时遇到问题.我正在使用Windows 7 64位元和Visual C ++ Express 2010,以及Gstreamer SDK 2012.11 32位元((

I'm new to Gstreamer, and I have problems when I compile the tutorial 1 of Gstreamer. I'm using Windows 7 64 bit with visual c++ express 2010, and Gstreamer SDK 2012.11 32 bits (downloaded from here). Here is the code :

#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.现在的行是:

So I just removed GST_MESSAGE_ERROR from the code. So the line is now :

msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_EOS);

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

I had the same problem with Ubuntu. But after that, in Ubuntu, I could play a video.

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

Second error : But with Windows, the compilation is good, but when I try to run it, I have thoses errors :

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一起使用.而且我真的不知道如何解决这个问题. 你能帮我吗?

I don't really understand why it works with ubuntu and not with Windows. And I really don't know how to solve this problem. Could you help me please ?

此致

推荐答案

l 第一个错误

可能代码被编译为C ++,这在枚举强制转换时更加严格.尝试更换: GST_MESSAGE_ERROR | GST_MESSAGE_EOS(GstMessageType)(GST_MESSAGE_ERROR | GST_MESSAGE_EOS)

Probably the code is compiled as C++, which is a bit more strict at enum casts. Try replacing: GST_MESSAGE_ERROR | GST_MESSAGE_EOS with (GstMessageType)(GST_MESSAGE_ERROR | GST_MESSAGE_EOS)

第二个错误

很有可能该行:

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

返回NULL,其余错误是由此导致的.为什么它可以返回NULL?原因有很多.也许您尚未安装带有"playbin2"的插件?试试这个:

returns NULL, and the rest of errors are result of this. Why it could return NULL? There are many reasons. Maybe you have not installed plugin with "playbin2"? Try this:

  • 将指向GError结构的指针作为gst_parse_launch的第二个参数传递(它具有message字段,可以为您提供一些提示)
  • 在运行程序时将--gst-debug-level=4或更高的值作为命令行参数传递.您会在控制台输出中看到许多信息,失败的原因可能在那里.
  • Pass a pointer to GError structure as second parameter to gst_parse_launch (it has a message field which can give you some hint)
  • Pass --gst-debug-level=4 or even higher as a commandline parameter when running your program. You will see many informations at console output, the reason of failure will be somewhere there.

这篇关于带有Visual C ++ Express 2010的Gstreamer-教程1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆