Camera

From The World according to Vissie
Jump to navigation Jump to search

Pi Camara

Install

Enabling the camera

Open the raspi-config tool from the Terminal:

sudo raspi-config

Select Interfacing Options then Camera and hit Enter. Choose Yes then ok. Go to Finish and you'll be prompted to reboot

setup device

v4l2-ctl --set-fmt-video=width=800,height=600
v4l2-ctl --set-fmt-video=width=1920,height=1080

Too much purple? Try this:

sudo vcdbg set awb_mode 0

video streaming

VLC fast

ls -l /dev/video0
crw-rw---- 1 root video 81, 6 Oct 19 11:04 /dev/video0
sudo adduser username video

cvlc v4l2:///dev/video0:width=640:height=480:fps=20 --sout="#transcode{vcodec=mp4v}:rtp{sdp=rtsp://:8554/}" :demux=h264

MJPG Streaming

v4l2-ctl --set-fmt-video=width=2592,height=1944,pixelformat=5
v4l2-ctl -c compression_quality=100,sharpness=30
v4l2-ctl -p 10
cvlc    --no-audio \
       v4l2:///dev/video0 \
       --v4l2-width 1920 \
       --v4l2-height 1080 \
       --v4l2-chroma MJPG \
       --v4l2-hflip 1 \
       --v4l2-vflip 1 \
       --sout '#rtp{sdp=rtsp://:8554/}' \
       -I dummy

HTTP H.264 Streaming

v4l2-ctl --set-fmt-video=width=2592,height=1944,pixelformat=4
v4l2-ctl -c sharpness=30,compression_quality=100,video_bitrate_mode=1,video_bitrate=25000000

cvlc    --no-audio \
       v4l2:///dev/video0 \
       --v4l2-width 1920 \
       --v4l2-height 1080 \
       --v4l2-chroma h264 \
       --v4l2-fps 30 \
       --v4l2-hflip 1 \
       --v4l2-vflip 1 \
       --sout '#standard{access=http,mux=ts,dst=:8554/}' \
       -I dummy

Password protection

To set up username and password authentication in a RTSP stream, you need to use the --sout-rtsp-user and --sout-rtsp-pwd.

The final command should be:

cvlc rtsp://ipcamlogin:ipcampassword@ipcamIP:554/play1.sdp --sout 

'#transcode{acodec=mp4a,ab=128,channels=2,samplerate=8000}:rtp{sdp=rtsp://rpiIP:8080/test.sdp}' --sout-ffmpeg-strict -2 --sout-avcodec-strict -2 --sout-rtsp-user username --sout-rtsp-pwd password

cvlc    --no-audio \
       v4l2:///dev/video0 \
       --v4l2-width 1920 \
       --v4l2-height 1080 \
       --v4l2-chroma h264 \
       --v4l2-fps 30 \
       --v4l2-hflip 1 \
       --v4l2-vflip 1 \
       --sout '#standard{access=http,mux=ts,dst=:8554/}' \
       --sout-rtsp-user username \
       --sout-rtsp-pwd password \
       -I dummy

raspivid slow

sudo raspivid -o - -t 0 -w 600 -h 400 -fps 20 -n | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

test local camera

sudo apt-get install qv4l2
qv4l2

sudo apt-get install qv4l2

USB Camara

setup

You can actually install vlc without support for X.

sudo apt install vlc-nox

or

sudo apt install vlc-bin

For now I will try motion. Setup looks big at 700M, but lets see if it works.

https://pimylifeup.com/raspberry-pi-webcam-server/

Some Usefull commans

sudo v4l2-ctl -d /dev/video0 --list-framesizes=YUYV
sudo v4l2-ctl --list-devices