• [+] Logitech C920 is a pretty good webcam easily recognized via many GNU Linux OS
  • [+] there is even the possibility to watch the cams via browser:
    • dashboard = all cmas overview: http://192.168.0.65:8080
    • 1st cam: http://192.168.0.65:8081/
    • 2nd cam: http://192.168.0.65:8082/
    • 3rd cam: http://192.168.0.65:8083/
  • [-] problem: motion can not capture audio 🙁
  • check out all possible config options
hostnamectl; # tested on
 Static hostname: rockpie1
       Icon name: computer
Operating System: Armbian 24.11.2 noble           
          Kernel: Linux 6.6.63-current-rockchip64
    Architecture: arm64

su - root
apt install motion v4l-utils ffmpeg
# attach a webcam to usb

# if there is a desktop installed
apt install cheese
# try out if webcam works
cheese

# test all identifiers, until one works

# using /dev/videoX device is no good
# because it keeps changing with every boot?
v4l2-ctl -d /dev/video0 --list-formats-ext
v4l2-ctl -d /dev/video1 --list-formats-ext
v4l2-ctl -d /dev/video2 --list-formats-ext
v4l2-ctl -d /dev/video3 --list-formats-ext; # <- video3 is the one to use
Size: Discrete 1920x1080 <- if cpu can handle the high resolution
# unfortunately RK3588 ARMv8 no GPU struggles and video will be choppy
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.042s (24.000 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.133s (7.500 fps)
Interval: Discrete 0.200s (5.000 fps)

# because it keeps changing with every boot?
# so try 
find /dev|grep usb

# try and use this identifier, that will survive reboots
v4l2-ctl -d /dev/v4l/by-id/usb-046d_HD_Pro_Webcam_C920_2FEF6ABF-video-index0 --list-formats-ext 
v4l2-ctl -d /dev/v4l/by-id/usb-046d_HD_Pro_Webcam_C920_2FEF6ABF-video-index1 --list-formats-ext 
apt install cheese
# create backup of config file
cp -rv /etc/motion/motion.conf /etc/motion/motion.conf.backup

# modify config file
sed -i 's/width 640/width 1920/g' /etc/motion/motion.conf

sed -i 's/height 480/height 1080/g' /etc/motion/motion.conf

sed -i 's/target_dir \/var\/lib\/motion/target_dir \/home\/user\/surveillance\/cam3/g' /etc/motion/motion.conf

sed -i 's/video_device \/dev\/video0/video_device \/dev\/v4l\/by-id\/usb-046d_HD_Pro_Webcam_C920_2FEF6ABF-video-index0/g' /etc/motion/motion.conf

sed -i 's/log_file \/var\/log\/motion\/motion\.log/log_file \/home\/user\/surveillance\/cam3\/motion\.log/g' /etc/motion/motion.conf

# in order for scripts to catch the log
# it might be wise to also have at least a link under /var/log
ln -sv /home/user/surveillance/cam3/motion.log /var/log/cam3.log

# rename the cam to cam3
sed -i 's/text_left CAMERA1/text_left cam3/g' /etc/motion/motion.conf

# per default it will save recordings.mkv
# if the user only wants jpgs (way faster = less strain on cpu)
sed -i 's/picture_output off/picture_output on/g' /etc/motion/motion.conf

sed -i 's/movie_output on/movie_output off/g' /etc/motion/motion.conf

# per default only a local browser on the machine is allowed to access the web dashbaord
# via localhost:8080 
# to allow access from other computers on the network:
sed -i 's/webcontrol_localhost on/webcontrol_localhost off/g' /etc/motion/motion.conf

sed -i 's/stream_localhost on/stream_localhost off/g' /etc/motion/motion.conf

# enhance basic security with htaccess over https auth
echo 'webcontrol_auth_method 1' >> /etc/motion/motion.conf
# MODIFY!
echo 'webcontrol_authentication admin:password' >> /etc/motion/motion.conf
# generate cert
cd /home/user

openssl genrsa -out webcontrol_key.pem 4096

openssl req -new -key webcontrol_key.pem -out webcontrol_csr.pem

openssl x509 -req -days 9999 -in webcontrol_csr.pem -signkey webcontrol_key.pem -out webcontrol_cert.pem

# enable https-ssl-tls encryption
echo 'webcontrol_key /home/user/webcontrol_key.pem' >> /etc/motion/motion.conf

echo 'webcontrol_cert /home/user/webcontrol_cert.pem' >> /etc/motion/motion.conf

echo 'webcontrol_lock_attempts 3' >> /etc/motion/motion.conf

echo 'stream_tls on' >> /etc/motion/motion.conf

echo 'webcontrol_tls on' >> /etc/motion/motion.conf

# in order to allow for rsync ssh upload without password auth to qnap nas
# on qnap nas: echo "thispublickey" >> /root/.ssh/authorized_keys
# upload recording to nas whenever finished
echo 'on_picture_save rsync -r -vv --update --progress /home/user/surveillance/cam3/ admin@192.168.0.231:/share/MD0_DATA/surveillance/cam3' >> /etc/motion/motion.conf

echo 'on_movie_end rsync -r -vv --update --progress /home/user/surveillance/cam3/ admin@192.168.0.231:/share/MD0_DATA/surveillance/cam3' >> /etc/motion/motion.conf

mkdir -p /home/user/surveillance/cam3

chown -R user:user /home/user/

# tested and did no good
# echo "threshold_maximum 25000" >> /etc/motion/motion.conf
# echo "threshold_tune on" >> /etc/motion/motion.conf

su - user

# watch the log
tail -f /home/user/surveillance/cam3/motion.log &

# now start the program
motion

# whenever something moves in front of the webcam
# there should also be busy activity on the terminal out

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin