Understanding the example with appsrc

Nicolas Dufresne nicolas at ndufresne.ca
Tue Feb 19 01:22:00 UTC 2019


Le lun. 18 févr. 2019 17 h 13, Wudo Balmus <wudo.balmus at gmail.com> a écrit :

> Hello,
> I'm trying to understand the example for appsrc element described in the
> official tutorial:
>
>
> https://gstreamer.freedesktop.org/documentation/application-development/advanced/pipeline-manipulation.html
>
> We specify caps like that:
>
>  g_object_set (G_OBJECT (appsrc), "caps",
>         gst_caps_new_simple ("video/x-raw",
>                      "format", G_TYPE_STRING, "RGB16",
>                      "width", G_TYPE_INT, 384,
>                      "height", G_TYPE_INT, 288,
>                      "framerate", GST_TYPE_FRACTION, 0, 1,
>                      NULL), NULL);
>
> Then, when need-data function is called, there is created a GstBuffer of
> size:
>
> size = 385 * 288 * 2;
>
> filled with some color and pushed to appsrc.
>
> Two questions:
>
> 1. Why there is component 385, not 384 in the size of the buffer? In caps
> there was specified that the width is 384, but in the size of the buffer
> 385 appeared.
>

385 is a typo, all the rest of the code uses 384. But as this will do
overallocation it should not cause any issue, would be nice to open an
issue against gst-docs, as this is confusing.

2. Why the size is multiplied by 2? Cannot we just send 1 frame? I tried to
> remove the *2 component, but then the background becomes a different colour
> than expected.
>

2 is the number of bytes per pixels for the chosen format. So
width*height*bps = size. Note though that in GStreamer you will have to
round up the width to a multiple of 2.

I tried also to modify duration, to make it 1fps, but still doesn't work.
>

The frame duration would also need to be set on buffers along with valid
timestamp.


> Best regards,
> Wudo
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190218/6d70741e/attachment-0001.html>


More information about the gstreamer-devel mailing list