This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: GStreamer pipelines to C Code

Part Number: AM5728

Tool/software: Linux

Hi

Can some one please help me out how to convert a working gsteamer pipeline into a c code.

gst-launch-1.0 v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, \
format=(string)YUY2, width=(int)1280, height=(int)720' ! vpe num-input-buffers=8 ! queue ! kmssink

Thanks,

Jahnavi

  • Hello,

    Please give me few hours to provide you examples.
    I will get back to you soon.

    Thank you!

    BR
    Margarita
  • Hello,

    This is the easy way with gst_parse_launch().


    #include <gst/gst.h>
    #include <stdio.h>

    int main(int argc, char *argv[])
    {
    GstElement *pipeline;
    GstBus *bus;
    GstMessage *msg;

    const gchar *nano_str;
    guint major, minor, micro, nano;


    /* Initialize GStreamer */
    gst_init (&argc, &argv);

    gst_version (&major, &minor, &micro, &nano);

    printf ("GStreamer Version: %d.%d.%d\n",major, minor, micro);


    /* Build the pipeline */

    pipeline = gst_parse_launch("v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! video/x-raw, format=(string)YUY2, width=(int)1280, height=(int)720 ! vpe num-input-buffers=8 ! queue ! kmssink", NULL);


    /* Start playing */

    gst_element_set_state (pipeline, GST_STATE_PLAYING);

    /* Wait until error or EOS */
    bus = gst_element_get_bus (pipeline);
    msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

    /* Free resources */
    if (msg != NULL)
    gst_message_unref (msg);
    gst_object_unref (bus);
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);
    return 0;
    }


    This is how you could build it on the board in case your .c is named capture.c
    gcc capture.c -o capture `pkg-config --libs --cflags gstreamer-1.0`

    this is how to run it:
    /etc/init.d/weston stop
    ./capture

    On my side this is working.

    I would recommend you to start with this tutorial because gst_parse_launch is not the only option.
    gstreamer.freedesktop.org/.../concepts.html

    Hope this helps.

    BR
    Margarita
  • Hello,

    Please if this answers your question click the "This resolved my issue" button.
    But if you have questions related to this issue please post a reply below.
    Thank you!

    BR
    Margarita
  • Sorry, for the late reply this resolved my issue.