Skip to content

Instantly share code, notes, and snippets.

@nitheeshkl
Last active July 15, 2020 14:38
Show Gist options
  • Save nitheeshkl/2791edddcb7812246c9394bc8319f0a8 to your computer and use it in GitHub Desktop.
Save nitheeshkl/2791edddcb7812246c9394bc8319f0a8 to your computer and use it in GitHub Desktop.
Bash completion for Gstreamer

Gstreamer Bash Completion

Bash completion or tab completion is the capability of the shell (bash in this case) to be able to autocomplete words for commands, parameters, etc. on hitting the tab key.

Bash completion for Gstreamer is the capability for gst-launch and gst-inspect to autocomplete elements and their corresponding pads and parameters. For example, gst-inspect-1.0 v4l2<tab> will show all the list of available elements (plugins) in the systems that start with v4l2.

$ gst-inspect-1.0 v4l2<tab>
v4l2radio  v4l2sink   v4l2src 

On Ubuntu (20.04 as of this writing), the default installation of Gstreamer from APT does not provide bash-completion. I could not find any installation packages or gst-plugins that enable bash-completion. However, bash-completion is a feature that is available in Gstreamer and is provided by https://github.com/GStreamer/gstreamer/tree/master/data/bash-completion. It looks like the Ubuntu distribution package of Gstreamer is not compiled with the bash-completion feature.

Therefore, bash-completion for Gstreamer can be enabled by a) building and installing Gstreamer from source or b) manually get these bash-completion files from Gstreamer source, modify it for pre-installed binaries, and place it in the bash-completion path.

Bash completion in Ubuntu

There are several ways to enable bash completion -- /etc/bash_completion.d/, /usr/share/bash-completion/, or ~/.bash_completion. Gstreamer, and other modern packages, use /usr/share/bash-completion/. This can be enabled as mentioned in the below sections.

Building from source

Follow the Gstreamer build-from-source instructions from official docs. As of writing, the latest version of Gstreamer (1.17.2) has bash completion enabled by default. If not it can be forcefully enabled with meson -Dgstreamer:bash-completion=enabled <build_dir>. Build and install will copy the required files to /usr/share/bash-completion/ or /usr/local/share/bash-completion or any other install prefix path.

Copying from source

If building Gstreamer from source is not preferred, bash-completion can still be enabled by copying all files from https://github.com/GStreamer/gstreamer/tree/master/data/bash-completion into the corresponding dirs under /usr/share/. Then, in /usr/share/bash-completion/helpers/gst, set _GST_HELPER variable to appropriate path for gst-completion-helper file. For example,

_GST_HELPER="/usr/libexec/gstreamer-1.0/gst-completion-helper"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment