Low Orbit Flux Logo 2 F

Raspberry Pi Camera CLI Commands Demo

Buy them on Amazon here ( affiliate links ):

Newer Commands

rpicam-jpeg command examples:



rpicam-jpeg -o test.jpg
rpicam-jpeg -o test.jpg -t 2000 --width 640 --height 480
rpicam-jpeg -o test.jpg -t 2000 --shutter 20000 --gain 1.5

rpicam-still command examples:



rpicam-still -o test.jpg
rpicam-still -e png -o test.png
rpicam-still -e bmp -o test.bmp
rpicam-still -r -o test.jpg       # raw

Get more info about images:



exiftool

More settings:



rpicam-still -o long_exposure.jpg --shutter 100000000 --gain 1 --awbgains 1,1 --immediate

Record a video:



rpicam-vid -t 10000 -o test.h264  # 10 sec video file

Different video formats:



rpicam-vid -t 10000 --codec mjpeg -o test.mjpeg
rpicam-vid -t 10000 --codec yuv420 -o test.data

UDP stream:



rpicam-vid -t 0 --inline -o udp://ip-addr:port
vlc udp://@:port :demux=h264
ffplay udp://ip-addr-of-server:port -fflags nobuffer -flags low_delay -framedrop

TCP stream:



rpicam-vid -t 0 --inline --listen -o tcp://0.0.0.0:port
vlc tcp/h264://ip-addr-of-server:port
ffplay tcp://ip-addr-of-server:port -vf "setpts=N/30" -fflags nobuffer -flags low_delay -framedrop

RTSP stream:



rpicam-vid -t 0 --inline -o - | cvlc stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/stream1}' :demux=h264
vlc rtsp://ip-addr-of-server:8554/stream1
ffplay rtsp://ip-addr-of-server:8554/stream1 -vf "setpts=N/30" -fflags nobuffer -flags low_delay -framedrop

Image detection:



rpicam-detect -t 0 -o cat%04d.jpg --lores-width 400 --lores-height 300 --post-process-file object_detect_tf.json --object cat

Older Commands and Steps for Older OS Versions

Might need to follow these steps to enable Raspberry Pi Camera on older versions of Raspberry Pi OS:

Older, deprecated camera commands:



raspistill -o Desktop/image.jpg
raspistill -o Desktop/image-small.jpg -w 640 -h 480

raspivid -o Desktop/video.h264

Outdated Python Info

Python Preview



from picamera import PiCamera
from time import sleep

camera = PiCamera()

camera.start_preview()
sleep(5)
camera.stop_preview()

Rotate



camera = PiCamera()
camera.rotation = 180

Set Alpha:



camera.start_preview(alpha=200)   # 0 255

Still Picture



camera.start_preview()
sleep(5)   # min 2 secs to detect light
camera.capture('/home/pi/Desktop/image.jpg')
camera.stop_preview()

Record Video



camera.start_preview()
camera.start_recording('/home/pi/Desktop/video.h264')
sleep(5)
camera.stop_recording()
camera.stop_preview()

Where to Buy

These Amazon links are paid affiliate links:

References