Appsrc example - variable framerate and setting duration to the buffers

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

Appsrc example - variable framerate and setting duration to the buffers

Wudo Balmus
Hello,
I'm trying to understand the example in Gstreamer tutorial with appsrc: https://gstreamer.freedesktop.org/documentation/application-development/advanced/pipeline-manipulation.html

There is written a sentence:

"We configure a video stream with a variable framerate (0/1) and we set the timestamps on the outgoing buffers in such a way that we play 2 frames per second."

then caps with variable framerate are set to appsrc:

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, <-- variable framerate
                     NULL), NULL);

and then when we generate each buffer, the duration is set for each buffer to 0.5s:

GST_BUFFER_DURATION (buffer) = gst_util_uint64_scale_int (1, GST_SECOND, 2);

The question is, why do we set the framerate to be variable (0/1)? Shouldn't we set it to constant 2 FPS instead as we generate 2 buffers each second?

Best regards,
Wudo

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

Re: Appsrc example - variable framerate and setting duration to the buffers

Nicolas Dufresne-5
Le samedi 16 mars 2019 à 20:02 +0000, Wudo Balmus a écrit :
Hello,
I'm trying to understand the example in Gstreamer tutorial with appsrc: https://gstreamer.freedesktop.org/documentation/application-development/advanced/pipeline-manipulation.html

There is written a sentence:

"We configure a video stream with a variable framerate (0/1) and we set the timestamps on the outgoing buffers in such a way that we play 2 frames per second."

then caps with variable framerate are set to appsrc:

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, <-- variable framerate
                     NULL), NULL);

and then when we generate each buffer, the duration is set for each buffer to 0.5s:

GST_BUFFER_DURATION (buffer) = gst_util_uint64_scale_int (1, GST_SECOND, 2);

The question is, why do we set the framerate to be variable (0/1)? Shouldn't we set it to constant 2 FPS instead as we generate 2 buffers each second?

I believe this is simply to show that you don't have to use fixed framerate and can use variable framerate. GStreamer synchronisation uses the timestamp, not the framerate for videos.


Best regards,
Wudo
_______________________________________________
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