Segmentation Fault

Tim-Philipp Müller t.i.m at zen.co.uk
Sat Jan 5 05:55:09 PST 2013


On Sat, 2013-01-05 at 09:12 +0000, Ian Davidson wrote:

Hi Ian,

> I am trying to write a GStreamer app where I  use a caps filter.  I have
> 
>    vcapsfilter  = gst_element_factory_make ("capsfilter", "vid-caps");
> 
> which appears to have been successful.
> 
> Then I tried
> 
>    g_object_set (G_OBJECT (vcapsfilter), "caps", 
> "video/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)25/1", 
> NULL);
> 
> When my program comes to execute that line I get a "Segmentation fault 
> (core dumped)" message.  I suspect that I must be doing something wrong 
> <grin>, but I don't know what I should be doing.  I have tried to wind 
> up the debug level to 9 but absolutely nothing gets logged.

The reason is that the "caps" property takes a GstCaps object/structure,
not a string. g_object_set() is a vararg function, so this kind of
mistake can not always be detected before crashing.

gst-launch-1.0/gst_parse_launch() converts things automagically from
string into the right type.

You have two options:

a)

  GstCaps *caps;

  caps = gst_caps_new_from_string ("video/x-raw,....");
  g_object_set (foo, "caps", caps, NULL);
  gst_caps_unref (caps);

b)

  gst_util_set_object_arg (foo, "caps", "video/x-raw,...");

Cheers
 -Tim



More information about the gstreamer-devel mailing list