If you search on the internet about RaspberryPi cameras and Shinobi you find a bunch of posts talking about setting up an RTSP stream for Shinobi to connect to. And on the Shinobi discord, a developer pointed to https://gitlab.com/Shinobi-Systems/shinobi-ip-camera. None of these instructions worked - I think they may have been for an older version of Raspbian. So firstly lets go through the software versions and hardware versions that I'm dealing with.
The hardware is a Raspberry Pi 3, and a Raspberry Pi ZeroW. Both of these have built in wifi which makes things easier. With these I'm using official Raspberry Pi cameras. I'm using the latest version of Raspbian at the time of writing - Raspbian GNU/Linux 10, and Shinobi ocean-1.
What eventually worked for me was adapted from a couple of web pages, particularly https://gist.github.com/neilyoung/8216c6cf0c7b69e25a152fde1c022a5d, and involved gst-rpicamsrc and gst-rtsp-server which contained the test-launch programme.
apt search libgstreamer
. At the time of writing this is libgstreamer1.0-0/stable 1.14.4-1 armhf. You then need to download the version of gst-rtsp-server that matches your libgstreamer1.0 version. So I downloaded gst-rtsp-server-1.14.4 from https://github.com/GStreamer/gst-rtsp-server and build that.sudo apt install gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-plugins-rtp
test-launch ( rpicamsrc bitrate=8000000 awb-mode=auto preview=false rotation=180 ! video/x-h264, width=960, height=540, framerate=10/1 ! h264parse ! rtph264pay name=pay0 pt=96 )
. This command had a resolution for a v1 camera. If you use a v2 camera you will want to choose a different resolution. I found this page to be useful for understanding the modes available.systemctl start cam-stream && systemctl enable cam-stream
.[Unit]
Description=auto start cam stream
After=multi-user.target
[Service]
Type=simple
ExecStart=/home/xxx/bin/test-launch ( rpicamsrc bitrate=8000000 awb-mode=auto preview=false rotation=180 ! video/x-h264, width=960, height=540, framerate=10/1 ! h264parse ! rtph264pay name=pay0 pt=96
User=xxx
WorkingDirectory=/home/xxx/shinobi
Restart=on-failure
[Install]
WantedBy=multi-user.target