Help with setting Caps in src code - not using gst-parse-launch

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

Help with setting Caps in src code - not using gst-parse-launch

JimmyHan
Hello Beginner here,

Started learning and understanding more n more with practice.
I have been searching up n down for examples on adding caps in code but after a few days I still don't have a clue.

E.g setting width and height, or denoise, detail, brightness, hue, frc-algorithm and the list goes on.
My boss has built a UI in html, php; where he has been able to add to inser text or choose from a drop down list options for the pipeline.

Looks like this screenshot of my setup:


My task was to add and integrate those options shown in the image. After choosing those options I then create a xml file, then read that xml file options into variables using an xmlreader.

For e.g I know a video source capabilities would include width and height.
I know how to add those caps using gst-launch-1.0 or gst-parse-launch


what I really wanna know is how do I get that done in code.
I don't even have any idea which element has capabilities such as the others shown in the image but for now I'd just like to how to add them in code.

I have seen e.g. such as:

GstElements *capsfilter;
GstCaps * caps;

capsfilter = gst_element_factory_make ("capsfilter", "capsfilter");
caps = gst_caps_new_simple ("video/x-raw", "width", G_TYPE_INT, 1920, "height", G_TYPE_INT, 1080, "framerate", G_TYPE_INT, 60, NULL);
g_object_set (capsfilter, "caps", caps, NULL);
gst_caps_unref (caps);

I'd also appreciate any idea or guide on adjusting these in code:
denoise, detail, brightness, hue, frc-algorithm, etc

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
Reply | Threaded
Open this post in threaded view
|

Re: Help with setting Caps in src code - not using gst-parse-launch

gotsring
I'm not entirely sure what you're asking, but I'll throw a few things at the
wall to see what sticks.

To set caps, you pretty much have the code already. Just add an element
called "capsfilter" and link it between the pipeline elements where you need
to specify the caps.

For example, the pipeline
    videotestsrc ! video/x-raw, format=I420, width=1920, height=1080,
framerate=20/1 ! autovideosink

becomes (in C code)

    // Create the elements
    GstElement* testsrc = gst_element_factory_make("videotestsrc",
"testsrc");
    GstElement* filter = gst_element_factory_make("capsfilter", "filter");
    GstElement* videosink = gst_element_factory_make("autovideosink",
"videosink");

    gst_bin_add_many(GST_BIN(pipeline), testsrc, filter, videosink, NULL);

    // Set the caps
    GstCaps* caps = gst_caps_new_simple(
        "video/x-raw",
        "format", G_TYPE_STRING, "I420",
        "width", G_TYPE_INT, 1920,
        "height", G_TYPE_INT, 1080,
        "framerate", GST_TYPE_FRACTION, 20, 1, NULL);
    g_object_set(G_OBJECT(filter), "caps", caps, NULL);

    // Link everything
    gst_element_link_many(testsrc, filter, videosink, NULL);

Some of those other things like brightness and rotation actually look like
element properties instead of caps. You can see what properties are
available for a specific element by using gst-inspect-1.0.

For example, 'gst-inspect-1.0 videotestsrc' shows us that there's a
"pattern" property that allows us to change what test pattern the
videotestsrc element produces. In code, we can set the pattern property
using
    g_object_set(G_OBJECT(testsrc), "pattern", 18, NULL);

This will show a moving ball instead of the regular test pattern.



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

AW: Help with setting Caps in src code - not using gst-parse-launch

Thornton, Keith
In reply to this post by JimmyHan

Hi,

I haven’t tried this myself but you might find something useful in the re-negotiation part of

https://gstreamer.freedesktop.org/documentation/plugin-development/advanced/negotiation.html?gi-language=c

Grüße

 

Von: gstreamer-devel <[hidden email]> Im Auftrag von JimmyHan
Gesendet: Freitag, 19. März 2021 02:35
An: [hidden email]
Betreff: Help with setting Caps in src code - not using gst-parse-launch

 

Hello Beginner here,

Started learning and understanding more n more with practice.
I have been searching up n down for examples on adding caps in code but after a few days I still don't have a clue.

E.g setting width and height, or denoise, detail, brightness, hue, frc-algorithm and the list goes on.
My boss has built a UI in html, php; where he has been able to add to inser text or choose from a drop down list options for the pipeline.

Looks like this screenshot of my setup:


My task was to add and integrate those options shown in the image. After choosing those options I then create a xml file, then read that xml file options into variables using an xmlreader.

For e.g I know a video source capabilities would include width and height.
I know how to add those caps using gst-launch-1.0 or gst-parse-launch


what I really wanna know is how do I get that done in code.
I don't even have any idea which element has capabilities such as the others shown in the image but for now I'd just like to how to add them in code.

I have seen e.g. such as:

GstElements *capsfilter;
GstCaps * caps;

capsfilter = gst_element_factory_make ("capsfilter", "capsfilter");
caps = gst_caps_new_simple ("video/x-raw", "width", G_TYPE_INT, 1920, "height", G_TYPE_INT, 1080, "framerate", G_TYPE_INT, 60, NULL);
g_object_set (capsfilter, "caps", caps, NULL);
gst_caps_unref (caps);

I'd also appreciate any idea or guide on adjusting these in code:
denoise, detail, brightness, hue, frc-algorithm, etc


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