-
Notifications
You must be signed in to change notification settings - Fork 0
GStreamer use cases with libcamera
If your pipeline fails to negotiate, use gst-validate-1.0 in place of gst-launch-1.0 for more information.
Then start with the basics and enable gst debug trace for warnings and errors. Prefix your launch line with GST_DEBUG=2 and if that's not sufficient, go noisy with: GST_DEBUG="CAPS:5"
Look for some lines saying "not compatible"
"reason not-negotiated (-4)" is usually cause by two of more links that aren't compatible to each other, for cameras its most of the time pixel format related
gst-launch-1.0 libcamerasrc ! fpsdisplaysink video-sink=fakesink text-overlay=false -v
(Not fully tested/guaranteed)
pi@mercury:~ $ cat multistream.sh
#!/bin/sh
export GST_DEBUG=5
export GST_DEBUG_FILE=multistream.log
gst-launch-1.0 \
libcamerasrc name=src \
src.src ! queue ! videoconvert ! autovideosink \
src.src_0 ! queue ! videoconvert ! autovideosink
Test with videotestsrc (courtesy of Triodes on #libcamera)
gst-launch-1.0 -vvvv \
videotestsrc pattern=ball ! \
'video/x-raw,width=1920,height=1080,framerate=30/1,format=NV12' ! \
v4l2h264enc ! 'video/x-h264,level=(string)4.2,profile=baseline' ! \
rtph264pay config-interval=-1 aggregate-mode=zero-latency ! \
udpsink host=127.0.0.1 port=8004
And then with libcamerasrc
gst-launch-1.0 -vvvv \
libcamerasrc camera-name="/base/soc/i2c0mux/i2c\@1/imx519\@1a" ! \
'video/x-raw,width=1920,height=1080,framerate=30/1,format=NV12,interlace-mode=progressive' ! \
v4l2h264enc ! 'video/x-h264,level=(string)4.2,profile=baseline' ! \
rtph264pay aggregate-mode=zero-latency config-interval=-1 ! \
udpsink host=127.0.0.1 port=8004
Note that currently the gstreamer element for libcamera might need explicit specification for the following properties:
- colorimetery
- framerate
- interlace-mode
For X264: x264enc tune=zerolatency
Robert Mader commented on a discussion: https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1455#note_1697993
All you'll need to change is the one line in `xdp-camera.py`:
```
pipeline = Gst.parse_launch('pipewiresrc fd=%d ! videoconvert ! xvimagesink'%(fd))
```
->
```
pipeline = Gst.parse_launch('pipewiresrc fd=%d ! videoconvert ! videoflip video-direction=auto ! xvimagesink'%(fd))
```
While on it you could replace it with something like:
```
pipeline = Gst.parse_launch('pipewiresrc fd=%d ! videoconvert ! videoflip video-direction=auto ! gtksink'%(fd))
```
or even
```
pipeline = Gst.parse_launch('pipewiresrc fd=%d ! glupload ! glcolorconvert ! gtkglsink rotate-method=auto'%(fd))
```
`gtksink` instead of `xvimagesink` has the advantage of working on Wayland.