Gstreamer with visual C ++ express 2010 - tutorial 1

I am new to Gstreamer and I am having problems compiling Gstreamer tutorial 1. I am using Windows 7 64-bit with visual C ++ express 2010 and Gstreamer SDK 2012.11 32 bit ( 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 the GST_MESSAGE_ERROR from the code. So now the line:

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 was able to play the video.

Second error: But with Windows the compilation is good, but when I try to run it I get 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 understand why it works with ubuntu and not Windows. And I really don't know how to fix this problem. could you help me?

Hello,

+3


source to share


2 answers


l First error

The code is probably compiled as C ++ which is a little stricter when enumerating an enum. Try replacing: GST_MESSAGE_ERROR | GST_MESSAGE_EOS

with(GstMessageType)(GST_MESSAGE_ERROR | GST_MESSAGE_EOS)

Second mistake

There is a high probability that the line:



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

      

returns NULL and the rest of the errors are the result of that. Why can it return NULL? There are many reasons. Perhaps you haven't installed the plugin from "playbin2"? Try the following:

  • Pass the pointer to the structure GError

    as the second parameter to gst_parse_launch

    (it has a field message

    that might give you some hint)
  • Pass --gst-debug-level=4

    or even higher as a command line parameter when starting your program. You will see a lot of information about the console output, the reason for the failure will be in there somewhere.
+11


source


I think you are using gstreamer 1.0, if I am not mistaken try using

"playbin" instead of "palybin2"



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

+1


source







All Articles