{"id":15197075,"url":"https://github.com/kraten/webcam-to-cctv-using-rpi","last_synced_at":"2025-10-28T07:30:42.218Z","repository":{"id":201473378,"uuid":"103452293","full_name":"kraten/webcam-to-cctv-using-rpi","owner":"kraten","description":"In this project, we will use a webcam with Raspberry Pi to live stream wirelessly.","archived":false,"fork":false,"pushed_at":"2017-09-13T23:41:45.000Z","size":18,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-01T12:44:09.752Z","etag":null,"topics":["cctv","linux","raspberry-pi","raspberry-pi-3","raspberry-pi-camera","surveillance","webcam"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kraten.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-09-13T21:22:28.000Z","updated_at":"2024-08-12T19:32:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"b192cc55-1b60-4b37-b03a-6bea4f9a2872","html_url":"https://github.com/kraten/webcam-to-cctv-using-rpi","commit_stats":null,"previous_names":["kraten/webcam-to-cctv-using-rpi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kraten%2Fwebcam-to-cctv-using-rpi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kraten%2Fwebcam-to-cctv-using-rpi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kraten%2Fwebcam-to-cctv-using-rpi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kraten%2Fwebcam-to-cctv-using-rpi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kraten","download_url":"https://codeload.github.com/kraten/webcam-to-cctv-using-rpi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238608362,"owners_count":19500365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cctv","linux","raspberry-pi","raspberry-pi-3","raspberry-pi-camera","surveillance","webcam"],"created_at":"2024-09-28T00:41:06.715Z","updated_at":"2025-10-28T07:30:36.918Z","avatar_url":"https://github.com/kraten.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"----------------------------------------------------------------------------\n RPI PROJECT : WEBCAM WIRELESS STREAM \n----------------------------------------------------------------------------\n\n// PROJECT DESCRIPTION ////////////////////////////////////////////////////////////////////////////////////////\n\t\n\tIn this project, we will use a webcam with Raspberry Pi to live stream wirelessly. However, it can also be \n\tdone with wired connection. The basic requirement is that both the Raspberry Pi and the device on which \n\tlive stream is to be viewed are connected with same network. Rather than using the Raspberry Pi camera\t\n\tmodule,\twe can use a standard USB webcam to take pictures and video on the Raspberry Pi. This project can \n\tbe used for monitoring purposes. For eg- CCTV live surveillance camera.\n\n// PRE-REQUISITE //////////////////////////////////////////////////////////////////////////////////////////////\n\t\n\t1. Raspberry Pi (Tested with RPi 3)\n\t2. Power Cable  (5V, 2A)\n\t3. Access to RPi Using SSH\n\t4. Webcam (Tested with Quantum QHM495LM)\n\n\t\n// BACKEND WORKING ////////////////////////////////////////////////////////////////////////////////////////////\n\t\n\tWe will use fswebcam app to capture images with RPi. fswebcam is a neat and simple webcam app. fswebcam \n\tprovides loop feature through which we can capture images in loop mode i.e. an image will be captured again\n\t\u0026 again in specified time interval. We can take advantage of loop mode to stream it like a video instead of\n\tstill image. \n\t\n\tFor streaming purpose, we will use MJPG Streamer. mjpg-streamer is a command line application that copies \n\tJPEG frames from one or more input plugins to multiple output plugins. It can be used to stream JPEG files \n\tover an IP-based network from a webcam to various types of viewers such as Chrome, Firefox, VLC, mplayer, \n\tand other software capable of receiving MJPG streams. MJPG streamer will take the image captured using \n\tfswebcam to display it as a live webcam stream over an ip address which can be accessed by any device such\n\tas smartphone, laptop, desktop, etc. connected to the same network as Raspberry Pi.\n\n\t\n// LIVE STREAMING USING RASPBERRY PI ////////////////////////////////////////////////////////////////////////////////////////////\n\n\n\u003cSTEP 1\u003e INSTALL BUILD DEPENDENCIES \n\t\n\tOpen a new terminal window.\tTo install the three libraries that MJPG-Streamer uses, execute the following \n\tcommand:\n\t\t$ sudo apt-get install libjpeg8-dev imagemagick libv4l-dev\n\n\u003cSTEP 2\u003e ADD MISSING VIDEODEV.H \n\n\tThe videodev.h header file that MJPG-Streamer needs has been replaced with a videodev2.h so we need to \n\tcreate a symbolic link.\tA symbolic link is where a file in one directory acts as a pointer to a file in \n\tanother directory. To create symbolic link:\n\t\t$ sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h\n\n\u003cSTEP 3\u003e DOWNLOAD MJPG STREAMER\n\n\tTo download the source code of MJPG Streamer from terminal:\n\t\t$ wget http://sourceforge.net/code-snapshots/svn/m/mj/mjpg-streamer/code/mjpg-streamer-code-182.zip\n\n-\u003e \tSometimes, the method provided below to download source code fails. In that case,download it manually\n\tfrom this link - http://sourceforge.net/p/mjpg-streamer/code/HEAD/tarball\n\n\u003cSTEP 4\u003e UNZIP MJPG STREAMER SOURCE CODE \n\t\n\tThe downloaded file is a compressed zip file so we need to extract the files to built it. Put the file in \n\thome directory(or a temporary folder, if you prefer) and run the following to extract the files:\n\t\t$ unzip mjpg-streamer-code-182.zip\n\n\u003cSTEP 5\u003e INSTALL BUILD DEPENDENCIES \n\t\n\tMJPG-Streamer comes with several plugins, but we only need a couple of them to stream video. The command \n\tbelow only builds what's needed:\n\t\t$ cd mjpg-streamer-code-182/mjpg-streamer\n\t\t$ make mjpg_streamer input_file.so output_http.so\n\n\u003cSTEP 6\u003e INSTALL MJPG STREAMER \n\n\tTo install the mjpg streamer, execute the following commands which will copy all the necessary into system \n\tdirectories:\n\t\t$ sudo cp mjpg_streamer /usr/local/bin\n\t\t$ sudo cp output_http.so input_file.so /usr/local/lib/\n\t\t$ sudo cp -R www /usr/local/www\n\t\t\n\u003cSTEP 7\u003e INSTALL FSWEBCAM\t\n\t\n\tTo install the fswebcam package:\n\t\t$ sudo apt-get install fswebcam\n\t\t\n\u003cSTEP 8\u003e START THE CAMERA\n\t\n\tNow, it's time to start the webcam:\n\t\t$ cd\n\t\t$ mkdir /tmp/stream\n\t\t$ fswebcam -l 1 -b --no-banner --save /tmp/stream/pic.jpg \n\n-\u003e fswebcam also provides several other options. For more info, enter following command: $ fswebcam --help\n\n\u003cSTEP 9\u003e START MJPG-STREAMER \n\n\tAlmost Done! Now, webcam started capturing images in loop. To start MJPG-Streamer, enter the following \n\tcommand in terminal:\n\t\t$ LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i \"input_file.so -f /home/pi/tmp/stream -n pic.jpg\" \n\t\t  -o \"output_http.so -w /usr/local/www\"\n\n\u003cSTEP 10\u003e WATCH THE STREAM \n\t\n\tTo watch live stream on same raspberry pi, visit http://localhost:8080 in your web browser. To watch it \n\tfrom any other device i.e. computer or smartphone, visit http://\u003cIP-address\u003e:8080 from your web\tbrowser. \n\tYou can find the IP address used by Raspberry Pi from your router's homepage. Click on stream on the \n\twebpage and your streaming will be live. All Done! Just relax and enjoy the live stream.\n\n\u003cSTEP 11\u003e CLEANUP \n\t\n\tAfter everything is working fine, we can remove the source files:\n\t\t$ cd ../../\n\t\t$ rm -rf mjpg-streamer-182\n\t\t\n\n\u003c BONUS \u003e SCRIPT TO AUTO LIVE STREAM AT STARTUP\n\n\tRun the start_live_stream.sh script on the startup to live stream from your webcam. You can run this script\n\tby executing the following command on the terminal:\n\t\n\t\t$ ./start_live_stream.sh\n\t\t\n\n\u003c BONUS \u003e STOP THE LIVE STREAM \n\t\n\tTo stop the live stream, we need to kill two processes- fswebcam and mjpg_streamer. Run the following\n\tcommands at the terminal, to find the Process ID's(PID) of the two processes:\n\t\n\t\t$ ps -e | grep mjpg_streamer\n\t\t$ ps -e | grep fswebcam\n\t\t\n\tAbove two commands will list the PID's of both the processes. Output of these commands will look like this: \n\t\t17306 pts/1    00:00:00 mjpg_streamer\n\t\t15982 ?        00:00:01 fswebcam\n\t\t\n\tNow to kill both the processes:\n\t\t$ sudo kill \u003cPID_of_mjpg-streamer\u003e\n\t\t$ sudo kill \u003cPID_of_fswebcam\u003e\n\t\t\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkraten%2Fwebcam-to-cctv-using-rpi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkraten%2Fwebcam-to-cctv-using-rpi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkraten%2Fwebcam-to-cctv-using-rpi/lists"}