Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gstreamer - Convert command line gst-launch to C code

I have been making a few experiments with GStreamer by using the gst-launch utility. However, ultimately, the aim is to implement this same functionality on my own application using GStreamer libraries.

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

An example of a command that I may need to port is:

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

What's the most "straight forward" way/approach to take such command and write it in C on my own app.

Also, as a side question, how could I replace the multifilesink with the possibility of doing this work on memory (I'm using OpenCV to perform a few calculation on a given image that should be extracted from the video). Is it possible to decode directly to memory and use it right away without first saving to the filesystem? It could (and should) be sequential, I mean that would only move on to the next frame after I'm done with processing the current one so that I wouldn't have to keep thousands of frames in memory.

What do you say?

like image 566
petersaints Avatar asked Jul 26 '11 21:07

petersaints


2 Answers

I found the solution. There's a function built in on GStreamer that parses gst-launch arguments and returns a pipeline. The function is called gst_parse_launch and is documented here: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstParse.html

I haven't tested it but it's possible the fastest solution to convert what have been testing on the command line to C/C++ code.

like image 174
petersaints Avatar answered Sep 20 '22 00:09

petersaints


You could always pop open the source of gst-launch and grab the bits that parse out the command-line and turn it into a GStreamer pipeline.

That way you can just pass in the "command line" as a string, and the function will return a complete pipeline for you.

like image 20
genpfault Avatar answered Sep 22 '22 00:09

genpfault