Gstreamer - convert gst-launch command line to C code

I did some experiments with GStreamer using the gst-launch utility. However, the ultimate goal is to implement the same functionality in my own application using the GStreamer libraries.

The problem is that it is ultimately difficult (at least for those who are not used for the GStreamer API) to "port" what I test on the command line to C / C ++ code.

An example of a command that may be needed for a port is:

gst-launch filesrc location="CLIP8.mp4" ! decodebin2 ! jpegenc ! multifilesink location="test%d.jpg" 

What is the most “direct” way / approach to take such a command and write it in C in my own application.

Also, as a side issue, how can I replace multifileink with the ability to do this job in memory (I use OpenCV to do a few calculations on a given image that needs to be extracted from the video). Is it possible to immediately decode the memory and use it immediately, without saving to the file system? It can (and should) be sequential, I mean that only after moving to the next frame, I would finish processing the current one so that I would not have to store thousands of frames in memory.

What do you say?

+6
source share
3 answers

I have found a solution. GStreamer has a built-in function that parses gst-launch arguments and returns a pipeline. This function is called gst_parse_launch and is documented here: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstParse.html

I did not test it, but this could be the fastest solution for converting C / C ++ code tested on the command line.

+10
source

You can always open the gst-launch source and capture bits that parse the command line and turn it into a GStreamer piping.

Thus, you can simply pass the "command line" as a string, and the function will return you a full pipeline.

+3
source

By the way, there is an interesting GStreamer element that provides a good way to integrate the processing pipeline into your application (C / C ++): appsink

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-appsink.html

With this, you can basically extract frames from the pipeline in a large C array and do whatever you want with them. You set up a callback function that will be activated every time a new frame is available from the pipeline stream ...

+1
source

Source: https://habr.com/ru/post/893638/


All Articles