How to use GstVideoAffineTransformationMeta in gstglimagesink

Matthew Waters ystreet00 at gmail.com
Tue May 17 17:21:55 UTC 2016


On 17/05/16 19:10, Grégoire Gentil wrote:
>
>
> On 05/17/2016 10:02 AM, Matthew Waters wrote:
>> On 16/05/16 01:57, Grégoire Gentil wrote:
>>> Hello,
>>>
>>> I'm interested to use GstVideoAffineTransformationMeta in
>>> gstglimagesink, especially in gst_glimage_sink_on_draw:
>>>
>>> https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/ext/gl/gstglimagesink.c#n2028
>>>
>>>
>>>
>>> I have a pad probe installed in my pipeline in which I do:
>>>
>>> static GstPadProbeReturn cb_have_data(GstPad *pad, GstPadProbeInfo
>>> *info, CustomData *data) {
>>>
>>> GstBuffer *buffer = gst_pad_probe_info_get_buffer (info);
>>>
>>> GstVideoAffineTransformationMeta *meta =
>>> gst_buffer_add_video_affine_transformation_meta (buffer);
>>>
>>> //To be modified
>>> const gfloat matrix[16] = {
>>> 0.1f, 0.0f, 0.0f, 0.0f,
>>> 0.0f, 1.0f, 0.0f, 0.0f,
>>> 0.0f, 0.0f, 1.0f, 0.0f,
>>> 0.0f, 0.0f, 0.0f, 1.0f,
>>> };
>>>
>>> gst_video_affine_transformation_meta_apply_matrix (meta, matrix);
>>>
>>>
>>> But when the code reaches gst_glimage_sink_on_draw, af_meta =
>>> gst_buffer_get_video_affine_transformation_meta
>>> (gl_sink->stored_buffer[0]); is NULL.
>>>
>>> Any idea how I could use GstVideoAffineTransformationMeta to have my
>>> own transform matrix?
>>
>> Most likely, you're using a pipeline that does not have an upstream
>> element that will add the GstVideoAffineTransformation so that's to be
>> expected.
>>
>> With the latest master of gst-plugins-bad, you can use gltransformation
>> which will build the GstVideoAffineTransformation for you and
>> glimagesink/glvideomixer will use that instead of gltransformation
>> performing a render pass.
>
> Thanks for the clarification. This is interesting and I recall having
> read gltransformation code but it doesn't do what I want, aka. having
> a specific transformation matrix. My ultimate goal is to crop the
> video. Can I do it with the existing property of gltransformation?

You can't crop in the general sense with gltransformation or the
GstVideoAffineTransformation when combined with other transformations
(rotate, perspective, etc).  What you can do to get a close-enough
effect for small crops with a transformation matrix is scale and
translate (using the scale-x, scale-y, translation-x and translation-y
properties) so that you only show the cropped area however this may
perform a non-uniform scale which will cause the aspect ratio to be
changed and degrade the video.

What needs to happen for this is that glimagesink needs to be able to
understand the GstVideoCropMeta and then one can use the videocrop
element to crop in GL.

Cheers
-Matt

> Grégoir 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160517/c7e70651/attachment.sig>


More information about the gstreamer-devel mailing list