From charlesreid1

Line 176: Line 176:
$ ./mjpg_streamer -i "./input_uvc.so -n -d /dev/video0" -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"
</pre>
</pre>





Revision as of 06:30, 21 August 2017

Mini CCTV camera that is embedded in a screw.

Hardware

The hardware required consists of:

  • The screw camera
  • A DVR video-to-USB dongle (preferably an EasyCAP converter)
  • A 5V USB to 5.5-to-2.1 mm DC power cable
  • Two male-to-male RCA jacks

Photos below.

The Camera

The screw camera is about $20 online. Here is a photo of the camera itself, in the screw housing:

ScrewCamera Camera.jpg

Here is a photo of the camera plus its RCA and power cables:

ScrewCamera CameraPlusCables.jpg

The yellow and white plugs are normal RCA jacks. The red one, though, is a DC power cable. When I first ordered the cable I had no idea what this was, and there was no information in the specs. It took some digging to figure out the size is a 5.5mm outer diameter, 2.1mm inner diameter DC power plug. The specs said it takes any voltage from 5V to 12V, but a reviewer on a similar mini camera said 12V fried the circuit. I ran this with 5V and it still runs very hot.

The Power Cable

Here is a closer look at the red cable, which is the DC power cable:

ScrewCamera CameraPowerCable.jpg

I bought a USB-to-DC converter/adapter for $3 online. It was USB on one end, 5.5/2.1mm DC jack on the other, and rated at 5V. Very convenient and much easier to deal with than a wall wart.

ScrewCamera DCPowerCable.jpg

The Video Converter

The last piece of equipment is a DVC USB converter, to convert the video signal from the camera to a digital signal. Also available online, for about $20. Here's a photo:

ScrewCamera DVCUSB.jpg

Two male-to-male RCA jacks are required to hook up the DVC USB converter to the camera's RCA outputs:

ScrewCamera Camera2DVCUSB.jpg

And finally, the power cable plugs into the red jack:

ScrewCamera Camera2DVCUSBPlusPower.jpg

Streaming 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 Streaming Software

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

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

ScrewCamera1.png

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:

ScrewCamera2.png

Note

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"