Configlet: Streaming video from a Pi to VLC using RTSP - bennest/ROV GitHub Wiki
Use sudo raspi-config to enable camera
To test that the camera is working:
vcgencmd get_camera
Streaming using VLC
sudo apt-get install vlc
Create a script to turn your Raspberry Pi into a RTSP streaming server.
Create the file /home/pi/stream-rtsp.sh:
#!/bin/bash raspivid -o - -t 0 -w 800 -h 600 -fps 12 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/stream}' :demux=h264
'sudo chmod +x stream-rtsp.sh'
Start it: './stream-rtsp.sh'
I did find a page that discussed performance with streaming, and how to assign more memory to the GPU and how to monitor performance or something… TODO
Set it to run on startup:
Sudo nano create the file /etc/systemd/system/stream-rtsp.service
[Unit] Description=auto start stream After=multi-user.target
[Service] Type=simple ExecStart=/home/pi/stream-rtsp.sh User=pi WorkingDirectory=/home/pi Restart=on-failure
[Install] WantedBy=multi-user.target
Set the service to auto start:
sudo systemctl enable stream-rtsp.service
Then you can start, stop, or check on the service with:
sudo systemctl start stream-rtsp.service
sudo systemctl stop stream-rtsp.service
sudo systemctl status stream-rtsp.service
View the stream using VLC
- Open VLC
- Open Network Stream
rtsp://192.168.1.9:8554/stream
Of course use your own camera IP address in the 3rd step above...