Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to copy from the original buffer buf (in the chain function) to another buffer created using:

GstBuffer *buffer;
glong size;

size = GST_BUFFER_SIZE(buf);
buffer = gst_buffer_new ();
GST_BUFFER_SIZE (buffer) = size;
GST_BUFFER_MALLOCDATA (buffer) = g_malloc (size);

But I get a segmentation fault. Is there anything wrong here?

share|improve this question

Rather than writing to the data the GstBuffer is managing, you're overwriting the GstBuffer object itself with your final memcpy call. Instead, you want to write to GST_BUFFER_DATA (buffer).

With that said if you just want a new buffer with the same data, it would seem easier to just use the gst_buffer_copy() function.

share|improve this answer
GstBuffer *buffer;
glong size;
size = GST_BUFFER_SIZE(inp);
buffer = gst_buffer_new();
GST_BUFFER_SIZE(buffer) = size;
GST_BUFFER_MALLOCDATA(buffer) = g_malloc(size);
buffer = GST_BUFFER_DATA(inp);

// Now you can use the data pointed by buffer to say write it in a file using fwrite

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.