RTSP Server

Set up a Real-time Streaming Server (RTSP)

Install the required packages:

raspberrypi ~ $ sudo apt-get install vlc

Run UV4L with the raspicam driver:

raspberrypi ~ $ uv4l --driver raspicam --auto-video_nr --framerate 25 --encoding=h264 --extension-presence=0
 [core] Device detected!
 [core] Registering device node /dev/video0

Optionally give a real-time scheduling policy to the driver process for better performance (which is the same as running uv4l with sudo uv4l –sched-rr):

raspberrypi ~ $ sudo chrt -a -r -p 99 `pgrep uv4l`

Run the real-time VideoLan streaming server on your Raspberry Pi with the preferred resolution:

raspberrypi ~ $ cvlc -vvv v4l2c:///dev/video0:width=640:height=480:chroma=H264 --sout '#rtp{sdp=rtsp://:8554/}' --demux h264

although more appropriate in theory, the above command has been reported to leak memory because of some buggy versions of cvlc. If this is the case, try the following alternative command to run the server:

raspberrypi ~ $ dd if=/dev/video0 bs=1M | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' --demux=h264

Now you can connect to your Raspberry Pi from the client, for example (don’t forget the final slash):

mypc ~ $ vlc rtsp://raspberrypi:8554/

where raspberrypi is the host name or IP of your RaspberryPi.

You can set any image property on the fly (while the camera is streaming). For example, to list all the available controls and change the brightness:

raspberrypi ~ $ sudo apt-get install v4l-utils
raspberrypi ~ $ v4l2-ctl --list-ctrls --device /dev/video0
 brightness (int) : min=0 max=100 step=1 default=50 value=50
 contrast (int) : min=-100 max=100 step=1 default=0 value=0
 saturation (int) : min=-100 max=100 step=1 default=0 value=0
 iso (int) : min=0 max=1200 step=1 default=400 value=400
 horizontal_mirror (bool) : default=0 value=0
 vertical_mirror (bool) : default=0 value=0
 sharpness (int) : min=-100 max=100 step=1 default=0 value=0
raspberrypi ~ $ v4l2-ctl --set-ctrl=brightness=50 --device=/dev/video0

A more user-friendly interface for changing the image properties while streaming with this/any method is the Conrol Panel web page coming along with the HTTP Streaming Server plug-in for UV4L.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close