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

gotsring gotsring at live.com
Fri Mar 19 04:14:23 UTC 2021


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/


More information about the gstreamer-devel mailing list