Recipes for Raspberry Pi Streaming Camera

In working on the time-lapse deck camera, I wanted to turn a Raspberry Pi with an HQ camera into an IP camera. There are two approaches I tried. Both worked. In the end, I would prefer the nginx solution, because it’s lighter and doesn’t cause the installation of XServer and crew on something like a headless Raspberry Pi Zero W!

RTSP Streamer with VLC

Prepare SD card (Used Raspberry Pi OS lite (no desktop))
Add the ssh & wpa_supplicant.conf files to the boot partition
Boot RPZW from S card

ssh pi@192.168.0.xxx
passwd
sudo raspi-config
sudo apt update
sudo apt full-upgrade
sudo apt install vlc
sudo nano rtsp-stream.sh

!/bin/bash
raspivid -o – -t 0 -rot 0 -w 1280 -h 720 -fps 30 -b 1250000 | cvlc -vvv stream:///dev/stdin –sout ‘#rtp{sdp=rtsp://:8554/stream}’ :demux=h264

sudo chmod +x rtsp-stream.sh
./rtsp-stream.sh

test with VLC “Network Stream”:

rtsp://192.168.0.120:8554/stream

Make it a service

sudo nano /etc/systemd/system/rtsp-stream.service

[Unit]
Description=Deck Camera Streaming Service
After=multi-user.target

[Service]
Type=simple
ExecStart=/home/pi/rtsp-stream.sh
User=pi
WorkingDirectory=/home/pi
Restart=on-failure

[Install]
WantedBy=multi-user.target

sudo systemctl enable rtsp-stream.service
sudo systemctl start rtsp-stream.service
sudo reboot

RTMP Streamer with nginx

Prepare SD card (Used Raspberry Pi OS lite (no desktop))
Add the ssh & wpa_supplicant.conf files to the boot partition
Boot RPZW from S card

sudo apt update
sudo apt full-ugrade
sduo reboot
sudo apt install libnginx-mod-rtmp
sudo rm sites-enabled/default
sudo systemctl start nginx.service
sudo systemctl status nginx.service

nginx.service should be running. If so, continue. if not? fix it

sudo nano /etc/nginx/rtmp.conf

rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
}
}

sudo nano /etc/nginx/nginx.conf

Add this line:

include /etc/nginx/rtmp.conf;

right here:

user www-data;
worker_processes auto;
pid /run/nginx.pid
include /etc/nginx/modules-enabled/*.conf;
include /etc/nginx/rtmp.conf; <— right here
sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl status nginx.service
netstat -an | grep 1935

OK, try VLC:

rtmp://192.168.0.164:1935/live/test

in OBS

Server: rtmp://192.168.0.164:1935/live
Key: test