Skip to main content

GStreamer Tips and Tricks

This page contains general tips and gotchas that we have found during development with GStreamer.

Testing Pipelines​

You can test pipelines directly in your CLI. For example:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=I420, width=1920, height=1080, framerate=30/1 ! videoconvert ! autovideosink

Sometimes it's also helpful to use a higher level of debug statements:

GST_DEBUG=3 gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=YUY2 ! videoconvert ! autovideosink

Testing GStreamer with OpenCV​

There is a Python script you can use to test GStreamer with OpenCV. You will have to change the pipeline to match yours. Download the test script example.

Camera Connectivity​

Check Connected Cameras​

This will show you all video devices recognized by the system:

ls /dev/video*

List Camera Formats​

v4l2-ctl --device=/dev/video0 --all

If you don't have v4l2 installed:

sudo apt-get install v4l-utils

You can also list recognized devices:

v4l2-ctl --list-devices

Verify Camera Reading​

Install ffmpeg if not already installed:

sudo apt install ffmpeg

Test the camera:

ffplay /dev/video0

Troubleshooting​

Camera Could Not Be Opened​

Sometimes the previous process did not close the camera. You'll need to kill it manually:

lsof /dev/video0
kill -9 <PID>

Missing Screen Error​

Sometimes you get an error in the pipeline because there's no attached screen. You can use a virtual screen:

sudo apt-get install xvfb
Xvfb :1 -screen 0 1920x1080x24 &
export DISPLAY=:1