I have been having great difficulty grasping the concept of GstMeta and using it from Python. A minimal-not-working-example can be found here.
I created a basic pipeline ([videotestsrc] - [capsfilter] - [xvimagesink[) with a buffer probe on the capsfilter src pad. My goal is to add GstVideoCropMeta to each passing buffer (in python). Xvimagesink already implements a get_meta for this metadata type so that should be easy to debug. Unfortunately, I am unable to figure out how to actually store x, y, width and height in the GstVideoCropMeta instance and making xvimagesink to pick-up these values. In C, things look fairly straightforward: smeta = (GstVideoCropMeta *) meta; dmeta = gst_buffer_add_video_crop_meta (dest); if (!dmeta) return FALSE; GST_DEBUG ("copy crop metadata"); dmeta->x = smeta->x; dmeta->y = smeta->y; dmeta->width = smeta->width; dmeta->height = smeta->height; Implying that, after doing the gst_buffer_add_video_crop_meta, I should store the x, y, width and height directly on its return value (a Gst.Meta). But that's doesn't really make sense right? Setting GST_DEBUG=xvimagesink*:8, I can see that xvimagesink is picking up the metadata, but x, y, width and height are still 0 (or worse, are sometimes random numbers from uninitialized memory locations making things crash and burn). I have been reading the docs a dozen times but I am still a bit lost. |
This post was updated on .
It turns out this is actually quite an old bug which was mentioned in this message on the Gstreamer list in November 2014. In short, we cannot assign values to a GstMeta object in python and recover them in C. The reverse, however, is possible using some tweaks.
I came up with the following work-around. First of all, use the latest gobject introspection bindings when compiling GStreamer from source. For this, you need to install: sudo apt-get install gobject-introspection libgirepository1.0-dev Also, add --enable-introspection when running autogen.sh when compiling the gstreamer packages autogen.sh --enable-introspectionand make sure you install the .typelib files in the proper folder. You can use python -c 'from gi.repository import Gst; print Gst'to check the location of the typelib files in use by pygi. Based on bug #702921 I was able to add a couple of publicly accessible methods (gst_buffer_get_video_meta and gst_buffer_set_video_meta) to gstvideometa.c and gstvideometa.h (gst-plugins-base) which allow me to explicitly set and get the contents of a GstVideoCropMeta metadata instance in the C environment. In python you can then use: from gi.repository import Gst, GstVideo # Add metadata to GstBuffer gstMeta = buffer.add_meta(GstVideo.VideoCropMeta.get_info(), 0) # Set metadata values to GstMeta GstVideo.buffer_set_video_crop_meta(gstMeta, 10, 20, 100, 200) # To verify whether we really wrote the metadata, we retrieve a fresh reference to the metadata on the GstBuffer gstVideoVideoCropMeta = GstVideo.buffer_get_video_crop_meta(buffer) # Should print 10 print gstVideoVideoCropMeta.x Note, as Stian Stelnes already mentioned in the bugreport above, the publicly accessible methods must be functions, not macros! |
On Mon, 2016-04-11 at 07:34 -0700, Arjen Veenhuizen wrote:
Hi Arjen, So maybe we need some setter functions for meta(s) then? Cheers -Tim -- Tim Müller, Centricular Ltd - http://www.centricular.com _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
This post was updated on .
Yes, I just filed a patch for setting the MetaStruct's fields to 0 on init, see.
I added a patch for the setter and getter as well (see #764902) |
Free forum by Nabble | Edit this page |