8

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

First error :

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

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

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

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

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 ?

Regards,

user2080718
  • 85
  • 1
  • 5

4 Answers4

21

lFirst error

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)

Second error

There is high probability, that the line:

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

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:

  • 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.
peper0
  • 3,111
  • 23
  • 35
2

I think you are using gstreamer 1.0, If I am not wrong then try to use

"playbin" instead of "palybin2"

"playbin2" is renamed to "playbin" from gstreamer 1.0

Shanmuka
  • 35
  • 2
0

Second error:

I would like to explain this for Ubuntu 16.04 LTS users.

To try examples from GStreamer tutorials sections you should compile & install from sources those repositories:

gstreamer
gst-plugins-base
gst-plugins-good

The reason is that versions used for the examples did not match versions I installed with apt (playbin was missing).

Before compiling from source you will also need dependencies to build vorbis, vpx and souphttpsrc plugins (they are parts of repositories mentioned). You can install them by running:

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

To check whether mentioned plugins were included in the repository build see ./configure output. If they were not maybe there are still some dependencies missing on your system. The output will tell you what's missing.

After that you should successfully compile and run the example (you should see a video playback).

A general flow for fixing initial installation problems with GStreamer is (as mentioned in accepted answer) using --gst-debug-level=4, finding out what plugins are missing and installing them.

pbn
  • 2,406
  • 2
  • 26
  • 39
0

For error 1 if you are compiling with c++ use: gst_bus_timed_pop_filtered(bus, GST_CLOCK_TIME_NONE, static_cast<GstMessageType>(GST_MESSAGE_ERROR | GST_MESSAGE_EOS)); instead of: gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);