By Oleksiy Grechnyev, IT-JIM, 2022.
This does not replace, but complements the official GStreamer tutorials. Here we focus on using appsrc
and appsink
for custom video (or audio) processing in the C++ code. In such situation, GStreamer is used mainly for encoding and
decoding of various audio and video formats.
Note: Our examples are written in C++ and not C. We are NOT using any GLib stuff we don't really need. This includes the GLib "main loop". Our code is well-commented. For the best experience, follow the examples in the order specified below.
On Linux, the code builds fine with CMake.
On other OS-es, you'll probably have to replace pkg-config
with something else.
OpenCV is used in some examples for custom image processing.
The examples:
fun1
: An (almost) minimal GStreamer C++ examplefun2
: Creating pipeline by hand, message processingcapinfo
: Information on pads, caps and elements, otherwise similar tofun2
video1
: Send video toappsink
, display withcv::imshow()
video2
: Decode a video file with opencv and send to a gstreamer pipeline viaappsrc
video3
: Two pipelines, with custom video processing in the middle, no audioaudio1
: Two audio pipelines, with custom audio processing in the middle, no videoav1
: Two pipelines, with both audio and video (video3
+audio1
combined !)