GStreamer basic tutorial 10: GStreamer tools

Posted by DrAxeman on Thu, 12 Mar 2020 07:37:33 +0100


GStreamer provides a series of convenient tools. There is no code involved in this tutorial, but there are still some useful things to talk about:

  • How to build a pipeline on the command line -- without using C at all
  • How to find out the Capabilities of an element
  • How to find the internal structure of a media file


These tools are located in the bin directory of the SDK. You need to add this directory to the PATH variable, or switch to the bin directory of GStreamer SDK currently.

Open a terminal interface, switch the current directory to the bin directory of GStreamer SDK, and then prepare to follow us.

In order to prevent conflicts caused by the installation of multiple versions of GStreamer, all tools have versions, and their names are followed by the version number of GStreamer. Because this version of SDK is 0.10, the tools are gst-launch-0.10, gst-inspect-0.10 and gst-discoverer-0.10.


This tool can create a pipeline, initialize it and run it. It allows you to quickly test the pipeline before writing code to see if it works.

Remember that this tool can only build simple pipelines. In particular, it can only simulate the interaction between pipeline and application at a specific level. In any case, it can test the pipeline very simply and quickly, and GStreamer developers all over the world use it every day.

Note that GST launch is primarily a debugging tool for developers. Instead of developing applications based on it, you should use the API gst_parse_launch() to create a pipeline.

Although the description of constructing a pipeline is very simple, the connection of multiple element s can quickly make things beyond your imagination. But don't be afraid. In the end, everyone can learn the grammar of GST launch.

The command line of GST launch includes a series of options after pipeline description. Some simple instructions will be mentioned below, and all relevant contents can be seen in the description document of GST launch.


Simply put, a pipeline-description is a series of uses! For separated elements, try the following command:

gst-launch-0.10 videotestsrc ! ffmpegcolorspace ! autovideosink

You can see an animated video window. Use CTRL+C to terminate the operation.

This example uses three element s: videotestsrc, ffmpeg colorspace and autovideo sink. GStreamer will connect their output pad and input pad. If there is more than one available input / output pad, the Caps of the pad will be used to determine the compatible pad.


Element may have attributes. In the command line, the format is "attribute = value". Multiple attributes are separated by spaces. You can use the GST inspect tool to check the attributes of the element (which will be discussed later).

gst-launch-0.10 videotestsrc pattern=11 ! ffmpegcolorspace ! autovideosink

You can see a static image of a series of concentric circles.

Named element

Element can use the name property to set the name, so that some complex pipeline s containing branches can be created. With a name, you can use the element created earlier, which is essential when using elements with multiple pad s (such as demuxer or tee).

A named element needs to be followed by a dot when using a name.

gst-launch-0.10 videotestsrc ! ffmpegcolorspace ! tee name=t ! queue ! autovideosink t. ! queue ! autovideosink

You can see two video windows showing the same content. If you see only one, try to move some window positions, maybe the other one is pressed.

In this example, video testsrc is first connected to ffmpeg colorspace, and then to tee element< GStreamer basic tutorial 07 - multithreading and pad effectiveness >As mentioned in), this tee is named "t", and then one channel is output to the queue and autovideo sink, and the other channel is output to another queue and autovideo sink.

queue is necessary here. For the reason, see< GStreamer basic tutorial 07 - multithreading and pad effectiveness>.


When connecting two elements, instead of letting GStreamer choose which pad to use, we prefer to specify the pad directly. We can do this by using the method of. + pad name after naming element (element must be named first). You can also use GST inspect to view the name of the pad in the element.

gst-launch-0.10.exe souphttpsrc location= ! matroskademux name=d d.video_00 ! matroskamux ! filesink location=sintel_video.mkv

This command uses soaphttpsrc to lock a media file on the internet, which is in webm format. We can use matroskademux to open this file, because the media contains audio and video, so we created two output pads, named video_andaudio_. We connect video_and matroskamux element, repackage the video stream, and finally connect it to filesink, so we save the stream to a file named singtel_video.mkv.

In short, we found a webm file, removed the sound, and only took out the video and saved it as a new file. If we want to maintain sound, then we should do this:

gst-launch-0.10.exe souphttpsrc location= ! matroskademux name=d d.audio_00 ! vorbisparse ! matroskamux ! filesink location=sintel_audio.mka

The vorbisparse element here will take some information from the stream and put it into the Caps of the Pad, so that the next element, matroskamux, can know how to handle the stream. It's not necessary to do this when capturing video, because matroskademux has already done it.

Note that in the two examples above, the media is not decoded and played. We just moved the data.

Caps filtering

When an element has more than one pad, it may be ambiguous to connect the next element, because the downstream element may have more than one compatible input pad, or its input pad can be compatible with all output pads. In this case, GStreamer will use the first pad that can be connected, which is equivalent to saying that GStreamer randomly finds a pad to connect.

Take a look at the following pipeline:

gst-launch-0.10 souphttpsrc location= ! matroskademux ! filesink location=test

The same media file and demuxer are used here as in the previous example. finksink input pad is in any format, which means it can accept all media formats. So which pad of matroskademux can get to filesink? Video or audio? We can't know.

In order to eliminate this kind of uncertainty, we used the method of pad name in the previous example. Here we introduce the method of Caps filtering:

gst-launch-0.10 souphttpsrc location= ! matroskademux ! video/x-vp8 ! matroskamux ! filesink location=sintel_video.mkv

A caps filtering action is similar to letting element do nothing but accept the given caps. In this example, we add a Caps filter of ievideo/x-vp8 between matroskademux and matroskamux, which indicates that we only need to be able to generate the output Pad of this type of video in matroskademux.

We need to use the GST inspect tool to view the Caps that can be accepted and generated by an element, and use the GST discoverer to view the Caps contained in the file. If we need to check the Caps generated by an element in the pipeline, use the - v parameter in GST launch.


Play a media file with playbin2 (and< GStreamer basic course 01 - Hello World )

gst-launch-0.10 playbin2 uri=

A normal playback pipeline.

gst-launch-0.10 souphttpsrc location= ! matroskademux name=d ! queue ! vp8dec ! ffmpegcolorspace ! autovideosink d. ! queue ! vorbisdec ! audioconvert ! audioresample ! autoaudiosink

A transcoding pipeline, after parsing webm, decodes all streams, re encodes audio and video into other formats, and then compresses them into Ogg files.

gst-launch-0.10 uridecodebin uri= name=d ! queue ! theoraenc ! oggmux name=m ! filesink location=sintel.ogg d. ! queue ! audioconvert ! audioresample ! flacenc ! m.

A pipeline to adjust the video scale. The video scale element can be resized and then output. In the example, Caps filter is used to set the video size to 320x200:

gst-launch-0.10 uridecodebin uri= ! queue ! videoscale ! video/x-raw-yuv,width=320,height=200 ! ffmpegcolorspace ! autovideosink

Get launch is a good place to start. If you need more information, please jab Here.


This tool has three operations:

  • Without parameters, it lists all the available elements, that is, all the elements you can use
  • With a file name, it will use this file as a plug-in of GStreamer, try to open it, and then list all internal element s
  • The element with a GStreamer will list all information of the element

Let's take an example:

gst-inspect-0.10 vp8dec
Factory Details:
  Long name:    On2 VP8 Decoder
  Class:        Codec/Decoder/Video
  Description:  Decode VP8 video streams
  Author(s):    David Schleef <>
  Rank:         primary (256)
Plugin Details:
  Name:                 vp8
  Description:          VP8 plugin
  Filename:             I:\gstreamer-sdk\2012.5\x86\lib\gstreamer-0.10\libgstvp8.dll
  Version:              0.10.23
  License:              LGPL
  Source module:        gst-plugins-bad
  Source release date:  2012-02-20
  Binary package:       GStreamer Bad Plug-ins (GStreamer SDK)
  Origin URL: 
Pad Templates:
  SRC template: 'src'
    Availability: Always
                 format: I420
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]
  SINK template: 'sink'
    Availability: Always
Element Flags:
  no flags set
Element Implementation:
  Has change_state() function: gst_base_video_decoder_change_state
  Has custom save_thyself() function: gst_element_save_thyself
  Has custom restore_thyself() function: gst_element_restore_thyself
Element has no clocking capabilities.
Element has no indexing capabilities.
Element has no URI handling capabilities.
  SRC: 'src'
      Has custom eventfunc(): gst_base_video_decoder_src_event
      Has custom queryfunc(): gst_base_video_decoder_src_query
        Provides query types:
                (1):    position (Current position)
                (2):    duration (Total duration)
                (8):    convert (Converting between formats)
      Has custom iterintlinkfunc(): gst_pad_iterate_internal_links_default
      Has getcapsfunc(): gst_pad_get_fixed_caps_func
      Has acceptcapsfunc(): gst_pad_acceptcaps_default
    Pad Template: 'src'
  SINK: 'sink'
      Has chainfunc(): gst_base_video_decoder_chain
      Has custom eventfunc(): gst_base_video_decoder_sink_event
      Has custom queryfunc(): gst_base_video_decoder_sink_query
      Has custom iterintlinkfunc(): gst_pad_iterate_internal_links_default
      Has setcapsfunc(): gst_base_video_decoder_sink_setcaps
      Has acceptcapsfunc(): gst_pad_acceptcaps_default
    Pad Template: 'sink'
Element Properties:
  name                : The name of the object
                        flags: readable, writable
                        String. Default: "vp8dec0"
  post-processing     : Enable post processing
                        flags: readable, writable
                        Boolean. Default: false
  post-processing-flags: Flags to control post processing
                        flags: readable, writable
                        Flags "GstVP8DecPostProcessingFlags" Default: 0x00000003, "demacroblock+deblock"
                           (0x00000001): deblock          - Deblock
                           (0x00000002): demacroblock     - Demacroblock
                           (0x00000004): addnoise         - Add noise
  deblocking-level    : Deblocking level
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 16 Default: 4 
  noise-level         : Noise level
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 16 Default: 0  

The most important thing here is:

  • Pad Templates: this section lists all kinds of pads and their Caps. Through these you can confirm whether you can connect to an element. In this example, there is only one ink Pad Template, which can only accept video/x-vp8 (video data is encoded in VP8 format); there is only one source Pad Template, which generates video/x-raw-yuv.
  • Attribute of element: all attributes of element and valid values are listed here.

For more information, see the GST inspect documentation.


This tool is a wrapper around the GstDiscoverer object. It can accept a URI entered from the command line and print out all the information. This is useful to see how media is encoded and reused, so that we can determine what element s to put in the pipeline.

Use GST discoverer -- help for help.

Let's take an example:

gst-discoverer-0.10 -v
Done discovering
  container: video/webm
    audio: audio/x-vorbis, channels=(int)2, rate=(int)48000
        audio/x-vorbis, channels=(int)2, rate=(int)48000
      Additional info:
      Language: en
      Channels: 2
      Sample rate: 48000
      Depth: 0
      Bitrate: 80000
      Max bitrate: 0
        taglist, language-code=(string)en, container-format=(string)Matroska, audio-codec=(string)Vorbis, application-name=(string)ffmpeg2theora-0.24, encoder=(string)"Xiph.Org\ libVorbis\ I\ 20090709", encoder-version=(uint)0, nominal-bitrate=(uint)80000, bitrate=(uint)80000;
    video: video/x-vp8, width=(int)854, height=(int)480, framerate=(fraction)25/1
        video/x-vp8, width=(int)854, height=(int)480, framerate=(fraction)25/1
      Additional info:
      Width: 854
      Height: 480
      Depth: 0
      Frame rate: 25/1
      Pixel aspect ratio: 1/1
      Interlaced: false
      Bitrate: 0
      Max bitrate: 0
        taglist, video-codec=(string)"VP8\ video", container-format=(string)Matroska;
  Duration: 0:00:52.250000000
  Seekable: yes
      video codec: On2 VP8
      language code: en
      container format: Matroska
      application name: ffmpeg2theora-0.24
      encoder: Xiph.Org libVorbis I 20090709
      encoder version: 0
      audio codec: Vorbis
      nominal bitrate: 80000
      bitrate: 80000


This tutorial shows:

  • How to use the gst-launch-1.0 tool to build and run the GStreamer pipeline from the command line.
  • How to use the gst-inspect-1.0 tool to find out the available GStreamer elements and their functions.
  • How to use to discover the internal structure of media files gst-discoverer-1.0.

Reference resources:

166 original articles published, 495 praised, 970000 visitors+
His message board follow

Topics: codec SDK Attribute Windows