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: gst pipeline to c code

Part Number: AM5728


Tool/software: Linux

Hi,

I'm working on a project in which we capture audio using a g-streamer pipeline.

I want to convert that g-streamer pipeline to a C code.

Suggest me how to convert a pipeline into C code with an explanation or a document.

Regards,

GAG

  • Hello Avinash Gowtham ,

    First, you need a working pipeline. You could test the pipeline in the console with gst-launch.

    After this you could use it in gst application.

    1. You could use gst_parse_launch() function.

    Here is example for video capture that is working on my side.

    In this example just replace the video capture pipeline with yours.

    #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

    Please notice that in the capsfilter(video/x-raw, format=(string)YUY2, width=(int)1280, height=(int)720) are missing " " or ' '.

    If there is a capsfilter in your pipeline please remove "" or '' when you use this with gst_parse_launch.

    2. The other way

    -create elements with gst_element_factory_make();

    -set properties  if any;

    -Add elements to the bin

    -link the elements this includes the capsfilters;

    -Add a message handler etc.

    Here are the gstreamer tutorials.

    Hope this helps.

    BR

    Margarita

  • Hello,

    Please if this answers your question click the "This resolved my issue" button.
    Thank you!

    Best regards,
    Margarita