From charlesreid1

No edit summary
Line 1: Line 1:
Mini CCTV camera that is embedded in a screw.
Mini CCTV camera that is embedded in a screw.


==Prerequisite software==
=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:
 
<pre>
$ apt-get -y install cmake imagemagick
</pre>
 
If you are on Kali:
 
<pre>
$ apt-get -y install libjpeg62-turbo-dev
</pre>
 
if you are on Debian/Raspbian/Ubuntu/other:
 
<pre>
$ apt-get -y install libjpeg8-dev
</pre>
 
===mjpg streamer===
 
Now install mjpg_streamer from SourceForge:


<pre>
<pre>
$ apt-get -y install guvcview
$ svn co https://svn.code.sf.net/p/mjpg-streamer/code/mjpg-streamer/ mjpg-streamer
</pre>
</pre>


Next install some prerequisite software for mjpg-streamer:
Now build it:


<pre>
<pre>
$ apt-get -y install cmake libjpeg62-turbo-dev
$ git clone https://github.com/jacksonliam/mjpg-streamer.git
$ cd mjpg-streamer/
$ cd mjpg-streamer/
$ cd mjpg-streamer-experimental
$ make
$ make
$ make install
</pre>
</pre>


==Flags==
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.


===Input Flags===
=Using=


When specifying the input .so, use the following flags:
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.


The <code>-d</code> flag is used to specify the device - for example, <code>/dev/video0</code>.
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.


The <code>-n</code> flag is useful for suppressing error messages about pan/tilt controls, which most cameras don't have anyway.
Below are some flags, then some commands:


The <code>-y</code> flag is used to specify YUYV format, in case the camera does not support mjpeg format.
==Flags==


The <code>-r</code> flag specifies the resolution, or whatever.
===Input Flags===


The <code>-f</code> flag specifies the frame rate.
When specifying the input .so, use the following flags:


IMPORTANT: The <code>-y</code> flag is used to specify YUYV format, in case the camera does not support mjpeg format.


IMPORTANT: The <code>-d</code> flag is used to specify the device - for example, <code>/dev/video0</code>.


==Errors==
IMPORTANT: The <code>-n</code> flag is useful for suppressing error messages about pan/tilt controls, which most cameras don't have anyway.


===Failure attempt 1: No image at all===
The <code>-r</code> flag specifies the resolution.


Tried this command, but no images showed up at all through the web interface - just a broken image icon:
The <code>-f X</code> flag specifies the frame rate as X.


<pre>
===Output Flags===
$ ./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -p 8080 -w ./www"
 
</pre>
IMPORTANT: The <code>-p</code> flag specifies the port where you access the live stream.


No images at all, just a broken image icon (again):
IMPORTANT: The <code>-w</code> flag specifies a folder where the web based stuff will live.


<pre>
The <code>-c</code> flag adds a username and password. Probably important if it goes on any real network.
$ ./mjpg_streamer -i "./input_uvc.so -n" -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............: MJPEG
o: www-folder-path...: ./www/
o: HTTP TCP port.....: 8080
o: username:password.: disabled
o: commands..........: enabled
</pre>


Broken image icon:
==Usage Examples==


<pre>
===Working Commands===
$ ./mjpg_streamer -i "./input_uvc.so -n -d /dev/video0" -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............: MJPEG
o: www-folder-path...: ./www/
o: HTTP TCP port.....: 8080
o: username:password.: disabled
o: commands..........: enabled
</pre>


===Semi Working Attempt 2===
The following command was the first success - except that it was the laptop's webcam.


<pre>
<pre>
Line 91: Line 95:
  o: commands..........: enabled
  o: commands..........: enabled
</pre>
</pre>
And the output in the web browser:


[[Image:ScrewCamera1.jpg|400px]]
[[Image:ScrewCamera1.jpg|400px]]


Bingo - except, that's the built-in webcam. Should have paid closer attention to the <code>/dev/</code> folder.
Should have paid closer attention to the <code>/dev/</code> folder.


<pre>
<pre>
Line 122: Line 124:


[[Image:ScrewCamera2.jpg|400px]]
[[Image:ScrewCamera2.jpg|400px]]
==A Useless Appendix==
===Failed Commands===
The following commands will not show any image at all through the web interface. The problem is a missing <code>-y</code> flag.
<pre>
$ ./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"
</pre>

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

File:ScrewCamera1.jpg

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:

File:ScrewCamera2.jpg

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"