DroneResponse / hardware-tests

0 stars 2 forks source link

Installation of GStreamer Version 1.20.1 #24

Open tawfiq1200 opened 2 years ago

tawfiq1200 commented 2 years ago

It has come to my understanding that the video streaming works with a specific version of GStreamer. Streamline Design is using version 1.20.1.

If we install the latest stable release from here then it will install the version 1.16.2. So, we need to build it from source to get the required version. The official documentation has two different ways of building from source.

I first built using Cerbero after git checkouting to 1.20.1 but after finishing the installation process, it still shows that the stable version (1.16.2) has been installed.

Then I tried the other method using Meson for which installation instructions are not accurate, there are missing dependencies. When I tried to run this command:

ninja -C gstreamer

I got the following error:

ninja: error: loading 'build.ninja': No such file or directory

As there are indeed no files named build.ninja but it seems to be needed.

So, we need to know exactly how to build version 1.20.1 from source. I have attached a picture for reference.

Screenshot from 2022-07-29 18-55-01

After installing GStreamer version 1.20.1, we should be able to get video streaming on the laptop by running the following command on the laptop as written in the manual:

gst-launch-1.0 udpsrc port=2100 caps='application/x-rtp, media=(string) video, clock-rate=(int) 90000, encoding-name=(string) H264' ! rtpjitterbuffer ! rtph264depay ! h264parse ! vaapih264dec ! videoconvert ! videobalance contrast=1.5 brightness=-.2 hue=0 ! autovideosink fps-update-interval=1000 sync=false

tawfiq1200 commented 2 years ago

I have found the build.ninja file, it was autogenerated by meson in the laptop's home directory. Now I can run: ninja -C gstreamer

We need to copy it to the build directory which is gstreamer. It was not in the instructions.

However, it keeps going and it seems to be in a loop. The last two lines in the screenshot are repeated every few minutes: Screenshot from 2022-07-29 19-51-34

n-snyder commented 2 years ago

@tawfiq1200, the pipeline should work with any version of gstreamer as long as you have the appropriate plug-ins in the pipeline. What errors are you seeing when you try to view the video?

tawfiq1200 commented 2 years ago

@n-snyder The first issue that shows up is this:

ERROR: pipeline could not be constructed: no element "udpsrc"

As you keep fixing, more issues related to encoding show up.

So, based on your comments, it seems that there are some plugins that need to be installed and it is not just a version of GStreamer. Is there any specific reason why you are using GStreamer 1.20.1? It needs to be built from source as you cannot use sudo install.... How exactly you did you do that? Did you do it on Ubuntu 20.04 or 18.04?

I think in the manual or in the Github repository, it would be nice to have the list of plugins that are required to be installed into the laptop. If we know the plugins, we can install them. It will be even nicer to have instructions to install them but at the least, we need to know what we need to install.

n-snyder commented 2 years ago

The reason for GStreamer 1.20.1 is that it comes preinstalled on Ubuntu 22.04 LTS. When I use the term plug-in, I mean the same as "element" in the error that you provided. So each name following the "!" is a different plug-in (shared library) that G-streamer uses to build the pipeline. "udpsrc" is one plug-in.

I am baffled why "udpsrc" was not on your system because that is an old plug-in that comes standard with G-streamer. I know that Gstreamer 1.14 contained it.

tawfiq1200 commented 2 years ago

@n-snyder

We got it working with almost real-time frame rate, this needs to go to the terminal or the bash rc file:

export GST_VAAPI_ALL_DRIVERS=1

This is probably because we are using Ubuntu 20.04.

The command in the manual seems to be correct but we had a frame rate issue which was fixed by this:

gst-launch-1.0 udpsrc port=2100 caps='application/x-rtp, media=(string) video, clock-rate=(int) 90000, encoding-name=(string) H264' ! rtpjitterbuffer ! rtph264depay ! h264parse ! vaapih264dec ! videoconvert ! videobalance contrast=1.5 brightness=-.2 hue=0 ! ximagesink

We changed autovideosink to ximagesink.

We also need to install this:

sudo apt-get -y install gstreamer1.0-vaapi

n-snyder commented 2 years ago

Great to hear! I am glad you have something working.

I noticed that some distributions contain the VAAPI decoder and others do not. Another good H264 decoder is v4l2h264dec.

For the video sink, there is may be a better video display option. You can try: gst-inspect-1.0 -a | grep sink to see what plug-ins you have available.