How to install Gstreamer on Ubuntu
2 min. read
Gstreamer is essential package for Ubuntu, but there could be some missing packages that are required for app development. So with next steps you are going to install Gstreamer on your PC.
Guide
Dockerfile
Checkout Dockerfile to build Docker Image for Ubuntu 18 and Gstreamer.
docker build -t gstreamer:latest /path/to/Dockerfile xhost +local: # To enable UI sudo docker run --name ubuntu-gstreamer -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix gstreamer:latest
Note: For Ubuntu 16.04 checkout Dockerfile
Go to Launch First Pipeline Section to check installation.
Locate Gstreamer
Check if any version of Gstreamer already installed
which gst-launch-1.0
If you see similar response
/usr/local/bin/gst-launch-1.0
You already have Gstreamer installed on your PC. But look at next steps to check that all required packages for development are also installed.
Check Gstreamer Version
Additional you can check version of installed package typing
gst-inspect-1.0 --version
You should get similar response in terminal
gst-inspect-1.0 version 1.14.1 GStreamer 1.14.1 (GIT)
Install Gstreamer
Update Packages
sudo apt-get update sudo apt-get upgrade sudo apt-get build-essential sudo apt-get pkg-config
Install main Gstreamer packages (*source)
sudo apt-get install libgstreamer1.0-0 gstreamer1.0-dev gstreamer1.0-tools gstreamer1.0-doc sudo apt-get install gstreamer1.0-plugins-base gstreamer1.0-plugins-good sudo apt-get install gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly sudo apt-get install gstreamer1.0-libav sudo apt-get install gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
Have you noticed words βbad, ugly, goodβ in libraries names? Donβt worry, those are not based on personal qualities π Here is an official doocumentation with explanation of each module and itβs name.
- gst-plugins-good – a set of good-quality plug-ins under our preferred license, LGPL
- gst-plugins-ugly – a set of good-quality plug-ins that might pose distribution problems
- gst-plugins-bad – a set of plug-ins that need more quality, testing or documentation
Launch first pipeline
Type in command line simple command to check that everything works as supposed:
gst-launch-1.0 videotestsrc ! autovideosink
Expected result should be something like this:
In case you installing Gstreamer on remote PC without any display, use fakesink instead of autovideosink.
Hope everything works just great and you are ready to make some awesome applications. If not, – leave a problem description in comments to this post. We are going to find a way to fix it π
FAQ
How to build Gstreamer from Sources?
- If there is a need to build gstreamer from sources, use the following guide
Hi Taras. Thanks for a neat and simple tutorial!
Could you also share your overall experience with GStreamer? How easy is to set up a simple pipeline to detect person faces on the video feed?
Hi, Yaroslav.
Thank you for question.
I started working with Gstreamer just a year ago. But I think Gstreamer is very powerful tool for data processing and analysis.
Now, I’m working on some interesting (open-source) projects to share. But you can look here – https://github.com/jackersson/gst-filter. Use it as simple Gstreamer setup in Python with OpenCV.
Oh, thanks, Taras! This is what I needed
Thank you for sharing superb informations. Your web site is so cool. I am impressed by the details that you’ve on this web site. It reveals how nicely you perceive this subject. Bookmarked this web page, will come back for more articles. You, my pal, ROCK! I found just the information I already searched everywhere and simply could not come across. What a perfect website.
after running : gst-launch-1.0 videotestsrc ! autovideosink
I got this error and no window shows, any help with that?
Setting pipeline to PAUSED …
Pipeline is PREROLLING …
Got context from element ‘autovideosink0’: gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)”\(GstGLDisplayX11\)\ gldisplayx11-0″;
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server “:0.0”
after 23 requests (22 known processed) with 0 events remaining.
It seems like you are using Gstreamer on Remote PC without desktop. If it so, you can’t run any plugin that involves GUI. So, the best choice is to substitute autovideosink with fakesink (that will drop buffers instead of showing them in window)
Hope it helped)
thanks ….it worked for me
Hi Taras. Thanks for this tutorial!
I’m trying to add libx265.so which built from x265 source (https://bitbucket.org/multicoreware/x265/wiki/Home) to pipeline and still stucking . Could you help me?
Hi Taras. Thanks for this tutorial!
I’m trying to add libx265.so which built from x265 source (https://bitbucket.org/multicoreware/x265/wiki/Home) to my GSTREAMER pipeline and still stucking. Could you help me?
Hi, David
Can you share with more details?
You want to use this plugin in your pipeline: https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-bad/html/gst-plugins-bad-plugins-x265enc.html ?
Keep up the good work! Thanks.
It’s hard to find knowledgeable people on this topic, but you seem like
you know what you’re talking about! Thanks
Worked for me, thanks!
Hi, do you know why the gstproxy package (proxysink, proxysrc) and the ipcpipeline package are not instllaed on Ubuntu 16.04?
Hi,
As far as I know ipcpipeline was presented in Gstreamer 1.14 and Ubuntu 16 has Gstreamer 1.8.3 installed. But on Ubuntu 18 it is there.The same with gst-proxy.
Additional reading: https://github.com/matthew1000/gstreamer-cheat-sheet/blob/master/sharing_and_splitting_pipelines.md#summary-of-methods-to-share-and-split-pipelines
Best regards,
Taras Lishchenko
Hi, there! I have a question. I want to instal gst-python from https://gstreamer.freedesktop.org/src/gst-python/, but it as I typed sh ./configure, it said checking for gstreamer-0.6 >= 0.6.0… configure: error: you need gstreamer development packages installed !… But I already install everything as this website says. Do you have any idea?
Hi, Jeff
It seems that you are trying to build gst-python against older version of gstreamer (that installed in your system). To check gstreamer version just type:
gst-launch-1.0 --version
And with:
git branch
or
git checkout -b {gstreamer-version}
Specify the right branch for building gst-python
Hope this helps π
Hi Taras,
After running gst-launch-1.0 videotestsrc | autovideosink, I get
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:
streaming stopped, reason not-linked (-1)
autovideosink: command not found
Hi Jim,
Check if package gstreamer1.0-plugins-good installed. Autovideosink is a part of that package.
If there will be any problem, please check installation requirements for Gstreamer on Ubuntu 18: https://bit.ly/2Meo8xP
Hope this helps π
Thank you very much for the content. I wish you continued success.
Hi Taras
Your tutorial is very complete, but for some reason, it did not solve my problem. I am trying to use a package named pocketsphynx with ROS to make speech to text than send the commands to my mobile robot. This package has pygst as depedency. When i try to run it (or if i check the directly with python i get the following result )
python
Python 2.7.17 (default, Nov 7 2019, 10:07:09)
[GCC 7.4.0] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import pygst
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named pygst
Note 1: I am using Ubuntu 18.
Note 2: In the installation process i have errors while installing
sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
E: Unable to locate package libgstreamer0.10-dev
E: Couldn’t find any package by glob ‘libgstreamer0.10-dev’
E: Couldn’t find any package by regex ‘libgstreamer0.10-dev’
E: Unable to locate package libgstreamer-plugins-base0.10-dev
E: Couldn’t find any package by glob ‘libgstreamer-plugins-base0.10-dev’
E: Couldn’t find any package by regex ‘libgstreamer-plugins-base0.10-dev’
Hi,
For proper Gstreamer installation I use dependency like in this DockerFile: https://bit.ly/2Meo8xP . Hope this helps!
If every dependency installed well, please tell me which project you are trying to launch and facing problem with pygst package?
I have installed it on Ubuntu 16.04 but could not be able to install these packages :
E: Unable to locate package gstreamer1.0-gl
E: Couldn’t find any package by glob ‘gstreamer1.0-gl’
E: Couldn’t find any package by regex ‘gstreamer1.0-gl’
E: Unable to locate package gstreamer1.0-gtk3
E: Couldn’t find any package by glob ‘gstreamer1.0-gtk3’
E: Couldn’t find any package by regex ‘gstreamer1.0-gtk3’
E: Unable to locate package gstreamer1.0-qt5
E: Couldn’t find any package by glob ‘gstreamer1.0-qt5’
E: Couldn’t find any package by regex ‘gstreamer1.0-qt5’
Could not find any solution on Google also.
All other than these three packages I have installed, and tried the test
gst-launch-1.0 videotestsrc ! autovideosink
It give me this error:
ERROR: pipeline could not be constructed: no element “videotestsrc”.
Hey Anas,
For Ubuntu 16 checkout Dockerfile. There are some differences in packages, so it a bit changed for Ubuntu 16.
Hope this helps π
Thank you, I have installed the packages on a fresh 16.04 Ubuntu and test it using gst-launch-1.0 videotestsrc ! autovideosink and it works as expected
Thanks alot for your help.
Great π
Glad it helped!
hi, iam trying to run gstreamer on google colab and while iam running this command ” !gst-launch-1.0 videotestsrc ! autovideosink” iam getting this error “XDG_RUNTIME_DIR not set in the environment”. this is the first time iam working with gstreamer and please help me with the issue..thanks in advance!
Hi Sai,
This error means that server PC have no connected display. And autovideosink plugin is specifically designed to display video. So I suggest you to use fakesink instead:
! gst-launch-1.0 videotestsrc ! fakesink
Tested in this Colab π
If you want to display result you have 2 options:
– record video into a file and display it with IPython.display solution
– of use “appsink” plugin to receive buffer from pipeline and refresh IPython.display (Check “How to work with appsink“)
Best regards,
hey taras,thanks for the reply!! so with fakesink we cannot see the video but we can only see wether the pipeline is running properly or not right(correct me if iam wrong)? and if i need to setup the same gstreamer with python bindings in windows,apart from the official documentation can i get any other sources or guides for installation in windows?because the process in documentation seems to be quite confusing and i couldnt find any proper resources apart from this link-https://stackoverflow.com/questions/17278953/gstreamer-python-bindings-for-windows.
Hi, when i was trying to play two videos at a time ,one video is getting black and the other is playing.i couldn’t able to figure it out.here is my pipeline
gst-launch-1.0 filesrc location=”play.mp4″ ! decodebin ! queue ! videobox border-alpha=0 right=-960 ! videomixer name=mix ! autovideosink filesrc location=”entrance_inside.mp4″ ! decodebin ! queue ! videobox border-alpha=0 left=-960 ! mix.
please help me with my problem..
Hi Sarat,
For me the following command worked:
gst-launch-1.0 videotestsrc ! video/x-raw,height=540,width=960 ! queue ! videobox border-alpha=0 left=-960 ! videomixer name=mix ! autovideosink videotestsrc pattern=ball ! video/x-raw,height=540,width=960 ! decodebin ! queue ! videobox border-alpha=0 left=0 ! mix.
To remember, just imaging that next command expanding your width to 960 from left with black image (1). So now image (960×2)x540
videobox border-alpha=0 left=-960
And this, do nothing to image (2), 960×540:
videobox border-alpha=0 left=0
Then, mixer just blends them: black part from (1) to be replaced by image from (2).
An example with video files
Best regards,
thanks taras for the rly..it is working with one modification for the pipeline you wrote.
Hi Sarat,
I’m glad to hear π
What did you change?
since i am using my local videos i used two decodebins ,and it worked for me.