Filling Gst.Buffer in Python

Tim-Philipp Müller t.i.m at zen.co.uk
Wed May 22 15:32:25 PDT 2013


On Wed, 2013-05-22 at 16:42 +0300, Tanel Alumäe wrote:

Hi,

> I'm trying to use Python to create a Gst.Buffer filled with some data,
> and push it to a Gstreamer pipeline via appsrc. I'm using GStreamer
> 1.0.7 under Debian (amd64, package name
> is gir1.2-gstreamer-1.0_1.0.7-1_amd64.deb), python 2.7.
> 
>
> My implementation is available
> here: https://gist.github.com/alumae/5627250#file-test_buffer-py
> 
> 
> The problem is that the data that is pushed to the Gstreamer pipeline
> and that is finally dumped by the filesink, is not exactly what I'm
> trying to push. Namely, the actual data seems to be prepended by 36
> bytes of "garbage". 
> 
> 
> More, exactly, I'm trying to push the string:
> 123412341234123412341234123412341234123412341234
> 
> 
> 
> What is actually pushed:
> <36 bytes of garbage>123412341234
> 
> 
> 
> It seems that the fill method is actually using the reference to the
> python object, not the actual array, and the 36 bytes is just the
> Python object header.

> Is there some other way (perhaps via MapInfo?) to set the Gst.Buffer
> data in Python? 

No, the MapInfo stuff doesn't work in python (or anything
gobject-introspection) at all. 

  https://bugzilla.gnome.org/show_bug.cgi?id=678663

has the whole story with all the gory details.

Your test program works for me with git master. I have changed two
things: (a) I have changed filesink location=xyz to fakesink dump=true
and (b) I had to remove the len(data) parameter, it should just be
buf.fill(0,data).

There was a problem with the gobject-introspection annotation of
gst_buffer_fill. It's been fixed in


http://cgit.freedesktop.org/gstreamer/gstreamer/commit/gst/gstbuffer.c?id=ec16d6b0a47b62acda1cfe10d70e83a67f1948f5

and I suspect it's what also fixes your issue.

We should probably cherry-pick it into the 1.0 branch, or at least the
fixes without the new function.

Cheers
 -Tim




More information about the gstreamer-devel mailing list