Posts

Showing posts with the label camera

Poor man's DVR - a linux bash script to capture images from the camera and upload them to a remote server

I wanted to create a very easy "DVR" script for my raspberry PI machine that will take a shot from the camera and upload the photos to a remote server so I can see what is happening in my living room. I created this simple bash Linux command line script to activate the camera, save the photo, add a timestamp and upload it to a remote server. It is running every minute - capturing 5 photos from the webcam every 9 seconds and uploads them to the server using scp. Here is the shell script for a poor man's DVR: #!/bin/bash # repeat 5 times for i in {1..5}; do     # the file name with a datetime stamp     filename=webcam_$(date +%Y%m%d-%H%M%S).jpg       # capture the image from the camera     ffmpeg -f video4linux2 -input_format mjpeg -i /dev/video0 -vframes 1 -frames:v 1 /mnt/ramdisk/$filename     # wait     sleep 9 done # create a latest.jpg image cp /mnt/ramdisk/$filename /mnt/ramdisk/latest.jpg...

Linux Ubuntu Installing and Using Fake Camera Stream

If you wish to create a virtual camera in Linux and stream "fake" videos during calls: To install the loopback camera: sudo apt update sudo apt install v4l2loopback-dkms v4l2loopback-utils To add the loopback camera module: sudo modprobe v4l2loopback card_label="My Fake Webcam" exclusive_caps=1 or sudo modprobe v4l2loopback devices=1 video_nr=1 card_label='MyWebCam' exclusive_caps=1 Now to stream the video: First find the list of videos device available: v4l2-ctl --list-devices You can check the videos by playing: ffplay /dev/videoX ffplay Rick_Astley_Never_Gonna_Give_You_Up.mpg Now you can stream the video to the free one: ffmpeg -re -i Rick_Astley_Never_Gonna_Give_You_Up.mpg -map 0:v -f v4l2 /dev/videoX Or ffmpeg -stream_loop -1 -re -i video.mp4 -vcodec rawvideo -threads 0 -f v4l2 /dev/videoX To remove the module from the kernel: sudo modprobe --remove v4l2loopback Software for streaming: sudo apt-add-repository ppa:obspro...