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: convert g-streamer pipeline to c code

Part Number: AM5728


Tool/software: Linux

Hi,

I'm using a G-streamer pipeline to display the mp4 file in my location.

pipeline is :  gst-launch-1.0 filesrc location=/home/m/TearOfSteel-AV-Short-720x406.mp4 ! decodebin name=dec ! videoconvert ! autovideosink dec. ! audioconvert ! audioresample ! alsasink

Normally it is working, but my problem is in converting that pipeline to a C code

I want to convert the below decoders into c code

decodebin name=dec

autovideosink dec.

suggest me.

Regards,

GAG.

  • Hello,

    Please refer the below guides about  pads:
    gstreamer.freedesktop.org/.../pads.html
    gstreamer.freedesktop.org/.../media-formats-and-pad-capabilities.html

    Here is an example:
    gist.github.com/.../276365488873665d81a3f1230afa2d6f
    Refer this function:
    static void cb_new_pad (GstElement *element, GstPad *pad, gpointer data)
    {
    gchar *name;
    GstElement *other = data;

    name = gst_pad_get_name (pad);
    g_print ("A new pad %s was created for %s\n", name, gst_element_get_name(element));
    g_free (name);

    g_print ("element %s will be linked to %s\n",
    gst_element_get_name(element),
    gst_element_get_name(other));
    gst_element_link(element, other);
    }
    ....

    g_signal_connect (dec, "pad-added", G_CALLBACK (cb_new_pad), conv);


    Hope this helps.

    BR
    Margarita

  • Hello,

    Please refer the below guide:
    software-dl.ti.com/.../Foundational_Components_Multimedia.html
    You could find gst pipelines about decode where ducati is used and vpe.
    I would recommend you to try these pipelines.


    You could try this also:


    #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(" playbin uri=file:////home/m/TearOfSteel-AV-Short-720x406.mp4 video-sink=waylandsink audio-sink=alsasink", 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;

    }

    gstreamer.freedesktop.org/.../gstreamer-GstParse.html

    BR
    Margarita
  • Hi Margarita,

    Thanks for the reply. It is helpful to me.

    One more query is, I'm having a g-streamer pipeline in which i want to replace the decoder with other decoder which is useful in playback the video.

    My pipeline is :
    gst-launch-1.0 filesrc location=/home/g/TearOfSteel-AV-Short-1024x1024.mp4 ! decodebin ! videoconvert ! autovideosink

    I want to replace "decodebin" with other decoder, which is helpful in displaying the Mp4 video.

    suggest me.

    Regards,
    GAG.
  • Hello,

    Here you could find what decodebin do gstreamer.freedesktop.org/.../gst-plugins-base-plugins-decodebin.html

    These are TI decoders :

    ducatih264dec
    ducatimpeg4dec
    ducatimpeg2dec
    ducativc1dec
    ducatijpegdec

    I would recommend you to use ducati and VPE if possible because if you use software decoder and videoconvert the CPU will be high and frame drop could be observed.

    One of the option is to use playbin(gstreamer.freedesktop.org/.../gst-plugins-base-plugins-playbin.html).
    gst-launch-1.0 playbin uri=file:///<path_to_file> video-sink=kmssink audio-sink=alsasink
    This will link all the elements and it is easy to be use in c application.

    The other option is to use pipeline like this:
    gst-launch-1.0 -v filesrc location=example_h264.mp4 ! qtdemux ! h264parse ! ducatih264dec ! vpe ! 'video/x-raw, format=(string)NV12, width=(int)720, height=(int)480' ! kmssink

    Please change qtdemux if there is a need. You could check the available demuxers by using this command:
    gst-inspect-1.0 | grep "demux"

    As you could see in the above example kmssink is used as displaysink so please stop weston.
    /etc/init.d/weston stop
    If you are using waylandsink please do no stop weston.

    In the above example there is no audio branch only video but you could add it.
    That is why you must use a demuxer in the pipeline. Demuxer element has one input(sink) and N-1 src pad(outputs) one for each elementary stream contained in the container format(video, audio, subtitle ).
    You could run gst-inspect-1.0 qtdemux

    Here is example for demuxer
    gst-launch-1.0 -v filesrc location=<file> ! qtdemux name=demux demux.audio_0 ! queue ! <audioparser> ! <audiodecoder> ! alsasink demux.video_0 ! queue ! <videoparse> ! <videodecoder> ! waylandsink

    Hope this helps.

    BR
    Margarita
  • Hello,

    Thank you! If you have new question/issue please open a new thread.
    Please take a look into this
    gstreamer.freedesktop.org/.../playbin-usage.html
    there is an example of playbin in c application.

    BR
    Margarita