Simple video filter, changing pixel values

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

Simple video filter, changing pixel values

Lazar Todic
This post was updated on .
Hi everyone! I'm trying to write simple video filter which is only going to change Y component (for the start) of a video frame. I'm relatively new to GStreamer-1.0 developing and for now I succeeded to create simple filter which is behaving like a bridge, only transferring data in correct format to nveglglessink filter, using Boilerplate from official documentation. For purpose of changing Y component of a video frame I need to access the data of a buffer. It is very confusing for me how to achieve this while using documentation. Is there any simple example of a video filter which can be used as a tutorial on how to manipulate data of a buffer?
Reply | Threaded
Open this post in threaded view
|

Re: Simple video filter, changing pixel values

Nicolas Dufresne-4
Le mardi 14 juin 2016 à 05:30 -0700, Lazar Todic a écrit :
> Hi everyone! I'm trying to write simple video filter which is only going to
> change Y component (for the start) of a video frame. I'm relatively new to
> GStreamer-1.0 developing and for now I succeeded to create simple filter
> which is behaving like a bridge, only transferring data in correct format to
> nveglglessink filter. For purpose of changing Y component of a video frame I
> need to access the data of a buffer. It is very confusing for me how to
> achieve this while using documentation. Is there any simple example of a
> video filter which can be used as a tutorial on how to manipulate data of a
> buffer?

For video filter like this one, you'll want to sub-class GstVideoFilter
[1]. There is over 100 plugins already sub-classing this, so examples
shouldn't be hard to find. You'll find 3 examples in the following
source folder [3]. You should obviously learn GObject programming first
[4].

regards,
Nicolas

[1] https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugi
ns-base-libs/html/gst-plugins-base-libs-gstvideofilter.html
[2] https://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/gst/vi
deofilter
[4] https://developer.gnome.org/gobject/2.48/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Simple video filter, changing pixel values

Lazar Todic
Thanks very much Nicolas for answering quickly. Thanks for references. I figured it out that I should get comfortable with GObject programming first. By the way, I succeeded to access data of a buffer using gst_buffer_map(buf, &info, GST_MAP_READWRITE), gst_buffer_unmap(buf, &info) and info.data[i].
Reply | Threaded
Open this post in threaded view
|

Re: Simple video filter, changing pixel values

Kiran Kumar
Hi Lazor,

Even I am doing similar kind of stuff. What is the value of "info.size" you are getting? Is it 4096 bytes?

Your answer would be helpful for me.

Thanks,
Kiran

On Wed, Jun 15, 2016 at 1:24 AM, Lazar Todic <[hidden email]> wrote:
Thanks very much Nicolas for answering quickly. Thanks for references. I
figured it out that I should get comfortable with GObject programming first.
By the way, I succeeded to access data of a buffer using gst_buffer_map(buf,
&info, GST_MAP_READWRITE), gst_buffer_unmap(buf, &info) and info.data[i].



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Simple-video-filter-changing-pixel-values-tp4678030p4678053.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


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

Re: Simple video filter, changing pixel values

Lazar Todic
Hi, Kumar!

I'm getting size of 460800 bytes. The resolution of my input video is 640x480. I suppose that color space format that I'm working with is YUV420 or NV12, but it is yet to discover. :) Was I any of help?
Reply | Threaded
Open this post in threaded view
|

Re: Simple video filter, changing pixel values

Kiran Kumar
Thanks for the quick reply. I always get 4096 bytes.

GstMapInfo map;
static GstFlowReturn
gst_mynewplugin_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
      [....]

        gst_buffer_map (buf, &map, GST_MAP_READ);
        g_print("buffer size=%d\n", map.size);
        
       [.......]
}

The input image size is 512x512x8(bit depth)=2097152 bits. But, map.size is always = 4096 bytes.

I'm getting in terms of chunks where each chunk size is 4096 bytes. I need the entire frame. 

Are you setting the buffer size of the pad?

Thanks

On Wed, Jun 15, 2016 at 2:22 AM, Lazar Todic <[hidden email]> wrote:
Hi, Kumar!

I'm getting size of 460800 bytes. The resolution of my input video is
640x480. I suppose that color space format that I'm working with is YUV420
or NV12, but it is yet to discover. :) Was I any of help?



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Simple-video-filter-changing-pixel-values-tp4678030p4678057.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


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

AW: Simple video filter, changing pixel values

Thornton, Keith

Now that you have let me know what you are trying, the filesrc element has a blocksize of 4096. Try increasing it to your 512 * 512 and see what happens

 

Von: gstreamer-devel [mailto:[hidden email]] Im Auftrag von Kiran Kumar
Gesendet: Mittwoch, 15. Juni 2016 12:10
An: Discussion of the development of and with GStreamer
Betreff: Re: Simple video filter, changing pixel values

 

Thanks for the quick reply. I always get 4096 bytes.

 

GstMapInfo map;

static GstFlowReturn

gst_mynewplugin_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)

{

      [....]

 

        gst_buffer_map (buf, &map, GST_MAP_READ);

        g_print("buffer size=%d\n", map.size);

        

       [.......]

}

 

The input image size is 512x512x8(bit depth)=2097152 bits. But, map.size is always = 4096 bytes.

 

I'm getting in terms of chunks where each chunk size is 4096 bytes. I need the entire frame. 

 

Are you setting the buffer size of the pad?

 

Thanks

 

On Wed, Jun 15, 2016 at 2:22 AM, Lazar Todic <[hidden email]> wrote:

Hi, Kumar!

I'm getting size of 460800 bytes. The resolution of my input video is
640x480. I suppose that color space format that I'm working with is YUV420
or NV12, but it is yet to discover. :) Was I any of help?



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Simple-video-filter-changing-pixel-values-tp4678030p4678057.html

Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

 


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

Re: Simple video filter, changing pixel values

Lazar Todic
In reply to this post by Kiran Kumar
I just used official plugin template which generates entire code for plugin to work correctly. Only things I changed and added were CAPS and chain function. I didn't change size of the buffer. Maybe I am wrong, but maybe it depends on architecture of the platform. Im working on Nvidia Jetson tx1 platform. And my plugin is connected like this: ... ! omxh264dec ! myplugin ! nveglglessink -e

static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
    GST_PAD_SINK,
    GST_PAD_ALWAYS,
    GST_STATIC_CAPS ("video/x-raw, format = (string) NV12, width = (int) 640, height = (int) 480")
    );
same for src_factory.

gst_color_filter_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)// 5.
{
   [...]
   GstMapInfo info;
   gst_buffer_map(buf, &info, GST_MAP_READWRITE);
 
    g_print ("Size of the buffer: %d \n",gst_buffer_get_size(buf));
    g_print("Info size: %d \n", info.size);
    [...]
}

I hope this tells you something. :)
Reply | Threaded
Open this post in threaded view
|

Re: Simple video filter, changing pixel values

Kiran Kumar
In reply to this post by Thornton, Keith
Hi,

Since I am getting the input from filesrc, I had to change the blocksize of filesrc. Now it is working according to my requirement.

Thank you very much for your inputs :)

On Wed, Jun 15, 2016 at 3:31 AM, Thornton, Keith <[hidden email]> wrote:

Now that you have let me know what you are trying, the filesrc element has a blocksize of 4096. Try increasing it to your 512 * 512 and see what happens

 

Von: gstreamer-devel [mailto:[hidden email]] Im Auftrag von Kiran Kumar
Gesendet: Mittwoch, 15. Juni 2016 12:10
An: Discussion of the development of and with GStreamer
Betreff: Re: Simple video filter, changing pixel values

 

Thanks for the quick reply. I always get 4096 bytes.

 

GstMapInfo map;

static GstFlowReturn

gst_mynewplugin_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)

{

      [....]

 

        gst_buffer_map (buf, &map, GST_MAP_READ);

        g_print("buffer size=%d\n", map.size);

        

       [.......]

}

 

The input image size is 512x512x8(bit depth)=2097152 bits. But, map.size is always = 4096 bytes.

 

I'm getting in terms of chunks where each chunk size is 4096 bytes. I need the entire frame. 

 

Are you setting the buffer size of the pad?

 

Thanks

 

On Wed, Jun 15, 2016 at 2:22 AM, Lazar Todic <[hidden email]> wrote:

Hi, Kumar!

I'm getting size of 460800 bytes. The resolution of my input video is
640x480. I suppose that color space format that I'm working with is YUV420
or NV12, but it is yet to discover. :) Was I any of help?



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Simple-video-filter-changing-pixel-values-tp4678030p4678057.html

Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

 


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



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