Gstreamer is a tool to manipulate audio and video format. It works as a
pipeline. It can be used as a library in C or other languages but also feature a
command line pipeline building tool gst-launch
. On ubuntu 20.04, the tool is
called from the command line using gst-launch-1.0
.
example:
gst-launch-1.0 videotestsrc ! autovideosink
In this command line the videotestsrc
plugin output is plugged to the
autovideosink
plugin input.
!
is used to connect operator together. This command will generate a test
pattern and display it in a window. !
and
also to distinguish with the pipe character |
which can lead to unexpected
and hard to understand errors.
videotestsrc
, generates a patterns with moving static at the bottom right.
Useful options is pattern=
which change the type of pattern, for example:
gst-launch-1.0 videotestsrc pattern=ball! autovideosink
Another option is is-live=true
. Could be useful for streaming ?
autovideosink
will find a way to display a video on your system. On linux it
might use ximagesink
or xvimagesink
, on macos osxvideosink
. Those sinks
have different capacity and might not accept the same format, so prefer the use
of videoconvert
before autovideosink
unless you know what you are doing.
videoconvert
will convert an input video to an output video available to the
subsequent sink. Gstreamer plugins are sufficiently smart to negociate
input/output formats and choose the proper ones.
One surprising aspect of gstreamer is how you will determine the video format (resolution, framerate, color mode, etc). In that example:
gst-launch-1.0 -v videotestsrc pattern=snow ! video/x-raw,width=1280,height=720 ! autovideosink
The video format generated by videotestsrc
is not determined directly by
videotestsrc
through the use of options but by a special pluging, acting as a
passthrough, who's only purpose if to declare what video format its expecting.
videotestsrc
will then adapt its output, if it can, to match the expectation
of the subsequent plugin.
To debug, use -v
, -vv
or -vvv
.
For more debug logging, use env var GST_DEBUG
:
GST_DEBUG=5 gst-launch-1.0 videotestsrc pattern=ball ! autovideosink
To see more information on a particular subject, like caps negociation:
gst-launch-1.0 --gst-debug=GST_CAPS:6 videotestsrc ! autovideosink
To visualize the connections graph:
GST_DEBUG_DUMP_DOT_DIR=/tmp gst-launch-1.0 videotestsrc ! autovideosink
The generated .dot
files can then be viewed with xdot
on linux.
To inspect a plugin documentation:
gst-inspect-1.0 xvimagesink
Cheatsheets: