From charlesreid1

Mini CCTV camera that is embedded in a screw. Here's a quick demo of the camera's quality:

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.

ffmpeg can be used to capture the stream to a video file, which can be done from any computer that can access the live stream.

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"


Recording Software

You can capture the live stream directly to video by opening the stream with ffmpeg and directing the output to a file.

See Ffmpeg for more info on the ffmpeg program.

Basically for the input file we'll use the web address for the stream. You will need to be running mjpeg-streamer (see above). Using this approach, you can simultaneously watch the stream through the browser and record the stream to video.

Normal Capture

To capture things at the normal rate, you can use the following command:

$ ffmpeg -f mjpeg -i "http://192.168.0.2:8080/?action=stream" ./video.mov

If you output to .avi format, the quality looks substantially more crappy.

Here's a sample video of me solving a Rubik's Cube from the screw camera:

Slow Motion Capture

To get a slow motion capture, using 5 camera frames per second (slowed down by a factor of about 5), use the -r flag to specify the frame rate:

$ ffmpeg -f mjpeg -r 5 -i "http://192.168.0.2:8080/?action=stream" -r 5 ./slowmo_video.mov