How to use GstVideoAffineTransformationMeta in gstglimagesink

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use GstVideoAffineTransformationMeta in gstglimagesink

Gregoire Gentil
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?

Thanks in advance,

Grégoire
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to use GstVideoAffineTransformationMeta in gstglimagesink

Sebastian Dröge-3
On So, 2016-05-15 at 16:57 -0700, 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);
Do you get warnings about the buffer not being writable? You should do
something like

  info->data = gst_mini_object_make_writable (info->data);

and then get the buffer.

Apart from that what you're doing there should work.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to use GstVideoAffineTransformationMeta in gstglimagesink

Gregoire Gentil


On 05/17/2016 12:26 AM, Sebastian Dröge wrote:

> On So, 2016-05-15 at 16:57 -0700, 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);
>
> Do you get warnings about the buffer not being writable? You should do
> something like
>
>    info->data = gst_mini_object_make_writable (info->data);
>
> and then get the buffer.
>
> Apart from that what you're doing there should work.
Thanks for helping. No, I don't get any warning. My pipeline (on
Android) is:

filesrc location=%s ! qtdemux ! queue ! decodebin ! queue ! identity !
glimagesink

and my probe is on the sink pad of the identity element. Even with the
added line, I still don't get any meta inside glimagesink. I have also
tried on the sink pad of glimagesink without any success. The callback
looks like this:

static GstPadProbeReturn cb(GstPad *pad, GstPadProbeInfo *info,
CustomData *data) {
info->data = gst_mini_object_make_writable(info->data);
GstBuffer *buffer = gst_pad_probe_info_get_buffer(info);
GstVideoAffineTransformationMeta *meta =
gst_buffer_add_video_affine_transformation_meta(buffer);
const gfloat matrix[16] = {
        0.5f, 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);
return GST_PAD_PROBE_OK;
}

Grégoire
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to use GstVideoAffineTransformationMeta in gstglimagesink

Matthew Waters
In reply to this post by Gregoire Gentil
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.

Cheers
-Matt

> Thanks in advance,
>
> Grégoire
>



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (484 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to use GstVideoAffineTransformationMeta in gstglimagesink

Gregoire Gentil


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?

Grégoire

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to use GstVideoAffineTransformationMeta in gstglimagesink

Matthew Waters
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


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (484 bytes) Download Attachment