The Smell of Molten Projects in the Morning

Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.

RPi Camera RTSP Setup

The rpicam.cfg file holding the parameters for the Raspberry Pi watching the Prusa MK 4 printer:

bitrate=2000000 
framerate=15
timeout=0 
nopreview= 
codec=libav 
libav-format=mpegts 
width=1280
height=720
rotation=180
roi=0.00,0.00,1.0,1.0
hdr=auto

The RPi camera for the wren nest is just taped to the window, but has a configuration providing a bigger picture:

bitrate=2000000 
framerate=15
timeout=0 
nopreview= 
codec=libav 
libav-format=mpegts 
width=1920 
height=1080 
roi=0.00,0.00,1.0,1.0
hdr=auto

The useful pieces:

  • bitrate sets the average data rate, which may be too high for comfort outside your immediate LAN
  • framerate need not be as high as you think
  • nopreview prevents a preview picture while starting
  • width and height do the obvious thing, but don’t try to be too clever
  • roi picks the image from a specific part of the camera sensor, so you can adjust the image layout if you have a rigidly fixed camera
  • hdr doesn’t do anything for cheap RPi cameras

Putting all the fiddly config in a file reduces the command line invocation to a mere jawbreaker:

rpicam-vid --config rpicam.cfg -o - | cvlc stream:///dev/stdin --sout '#rtp{sdp=rtsp://:5886/wrens}' &

Although you’d want to set that up to run automagically when the RPi starts up, for now I just fire it off as needed through an SSH session, with the ampersand letting it run after that terminal session closes.

The RTSP port (5886) and stream (wrens) can be anything you like, which comes in handy when squirting streams through port-forwarded firewall pinholes using a router that cannot handle different external and internal port numbers.

Useful background info:

Comments

Spam comments get trashed, so don’t bother. Comment moderation may cause a delay.