ScrewCamera: Difference between revisions
From charlesreid1
No edit summary |
|||
| Line 27: | Line 27: | ||
</pre> | </pre> | ||
==mjpg streamer== | |||
Now install mjpg_streamer from SourceForge: | Now install mjpg_streamer from SourceForge: | ||
Revision as of 11:00, 19 August 2017
Mini CCTV camera that is embedded in a screw.
Hardware
Software
To stream video from the EasyCAP USB device, we'll use mjpg-streamer, which can send a live video stream to a website.
Installing Prerequisite Software
Install some prerequisite software for mjpg-streamer:
$ apt-get -y install cmake imagemagick
If you are on Kali:
$ apt-get -y install libjpeg62-turbo-dev
if you are on Debian/Raspbian/Ubuntu/other:
$ apt-get -y install libjpeg8-dev
mjpg streamer
Now install mjpg_streamer from SourceForge:
$ svn co https://svn.code.sf.net/p/mjpg-streamer/code/mjpg-streamer/ mjpg-streamer
Now build it:
$ cd mjpg-streamer/ $ make
We'll just make it in-place and leave the .so and binary files in the mjpg-streamer directory, instead of bothering with an install. If the make goes well, we are ready to rock and roll.
Using
The mjpg-streamer software basically takes an input .so file, along with some options, and an output .so file, along with other options. These allow you to send and receive video from/to various sources.
In this case we'll just be using the USB device as the video source, and the mjpg-streamer web interface as the output destination.
Below are some flags, then some commands:
Flags
Input Flags
When specifying the input .so, use the following flags:
IMPORTANT: The -y flag is used to specify YUYV format, in case the camera does not support mjpeg format.
IMPORTANT: The -d flag is used to specify the device - for example, /dev/video0.
IMPORTANT: The -n flag is useful for suppressing error messages about pan/tilt controls, which most cameras don't have anyway.
The -r flag specifies the resolution.
The -f X flag specifies the frame rate as X.
Output Flags
IMPORTANT: The -p flag specifies the port where you access the live stream.
IMPORTANT: The -w flag specifies a folder where the web based stuff will live.
The -c flag adds a username and password. Probably important if it goes on any real network.
Usage Examples
Working Commands
The following command was the first success - except that it was the laptop's webcam.
$ ./mjpg_streamer -i "./input_uvc.so -n -d /dev/video0 -y" -o "./output_http.so -p 8080 -w ./www" MJPG Streamer Version: svn rev: 3:172 i: Using V4L2 device.: /dev/video0 i: Desired Resolution: 640 x 480 i: Frames Per Second.: 5 i: Format............: YUV i: JPEG Quality......: 80 o: www-folder-path...: ./www/ o: HTTP TCP port.....: 8080 o: username:password.: disabled o: commands..........: enabled
Should have paid closer attention to the /dev/ folder.
$ /bin/ls /dev/video* /dev/video0 /dev/video1
Now trying video 1:
$ ./mjpg_streamer -i "./input_uvc.so -n -d /dev/video0 -y" -o "./output_http.so -p 8080 -w ./www" MJPG Streamer Version: svn rev: 3:172 i: Using V4L2 device.: /dev/video0 i: Desired Resolution: 640 x 480 i: Frames Per Second.: 5 i: Format............: YUV i: JPEG Quality......: 80 o: www-folder-path...: ./www/ o: HTTP TCP port.....: 8080 o: username:password.: disabled o: commands..........: enabled
And here we are:
A Useless Appendix
Failed Commands
The following commands will not show any image at all through the web interface. The problem is a missing -y flag.
$ ./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -p 8080 -w ./www" $ ./mjpg_streamer -i "./input_uvc.so -n" -o "./output_http.so -p 8080 -w ./www" $ ./mjpg_streamer -i "./input_uvc.so -n -d /dev/video0" -o "./output_http.so -p 8080 -w ./www"