mjpg streamer $5 webcam

Started by torqu3e, March 30, 2013, 12:06:48 AM

Previous topic - Next topic

torqu3e

olinuxino@olinuxino:~/mjpg-streamer/mjpg-streamer$ ./mjpg_streamer -i "input_uvc.so -f 15 -n -y" -o "output_http.so -p 8090"
MJPG Streamer Version: svn rev: 3:172M
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 15
i: Format............: YUV
i: JPEG Quality......: 80
o: www-folder-path...: disabled
o: HTTP TCP port.....: 8090
o: username:password.: disabled
o: commands..........: enabled
^Csetting signal to stop
i: cleaning up ressources allocated by input thread
force cancellation of threads and cleanup resources
o: cleaning up ressources allocated by server thread #00
done


It is a major pain to get this going, spent a good part of the day doing this, here are some instructions that should work.

sudo apt-get install fswebcam subversion libv4l-dev libjpeg8-dev imagemagick

Testing webcam working properly (assuming uvc drivers have been installed)...

$ fswebcam /dev/video0 foo.jpg -v
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
src_v4l2_get_capability,87: /dev/video0 information:
src_v4l2_get_capability,88: cap.driver: "uvcvideo"
src_v4l2_get_capability,89: cap.card: "U2 EE Cam"
src_v4l2_get_capability,90: cap.bus_info: "usb-sw-ehci-1.2"
src_v4l2_get_capability,91: cap.capabilities=0x04000001
src_v4l2_get_capability,92: - VIDEO_CAPTURE
src_v4l2_get_capability,103: - STREAMING
No input was specified, using the first.
src_v4l2_set_input,181: /dev/video0: Input 0 information:
src_v4l2_set_input,182: name = "Camera 1"
src_v4l2_set_input,183: type = 00000002
src_v4l2_set_input,185: - CAMERA
src_v4l2_set_input,186: audioset = 00000000
src_v4l2_set_input,187: tuner = 00000000
src_v4l2_set_input,188: status = 00000000
src_v4l2_set_pix_format,541: Device offers the following V4L2 pixel formats:
src_v4l2_set_pix_format,554: 0: [0x56595559] 'YUYV' (YUV 4:2:2 (YUYV))
Using palette YUYV
Adjusting resolution from 384x288 to 352x288.
src_v4l2_set_mmap,693: mmap information:
src_v4l2_set_mmap,694: frames=4
src_v4l2_set_mmap,741: 0 length=202752
src_v4l2_set_mmap,741: 1 length=202752
src_v4l2_set_mmap,741: 2 length=202752
src_v4l2_set_mmap,741: 3 length=202752
--- Capturing frame...
Captured frame in 0.00 seconds.
--- Processing captured image...
Fontconfig warning: ignoring C.UTF-8: not a valid language tag
Fontconfig warning: ignoring C.UTF-8: not a valid language tag
Writing JPEG image to '/dev/video0'.
gd-jpeg: JPEG library reports unrecoverable error: Output file write error --- out of disk space?
Writing JPEG image to 'foo.jpg'.


The output till Capturing frame is the important one, if this succeeds your camera is setup correctly and you can proceed to downloading and compiling the source code

svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer mjpg-streamer

Changing to the right directory with the Makefile

make clean all

Next you need to add your user to the video group else it will v4l2 will not be able to access the device.

$ sudo useradd -G olinuxino
$ su
$ id
uid=1001(olinuxino) gid=1002(olinuxino) groups=1002(olinuxino),4(adm),27(sudo),29(audio),44(video),105(netdev)


Add user, switch user (so that the permissions get applied without a reboot), display user ids 44(video) listed means we are good.

Try running the streamer now from the same directory where you ran the make.

/mjpg_streamer -i "input_uvc.so -n " -o "output_http.so -p 8090"

if that errors out with a v4l2 error and your fswebcam output has lines similar to this(basically YUYV output format)...

src_v4l2_set_pix_format,541: Device offers the following V4L2 pixel formats:
src_v4l2_set_pix_format,554: 0: [0x56595559] 'YUYV' (YUV 4:2:2 (YUYV))
Using palette YUYV


Use this instead...

./mjpg_streamer -i "input_uvc.so -y" -o "output_http.so -p 8090"

If that works, you can go to http://olinuxino.local:8090/?action=stream

The -f lets you set frame rate, -p sets the tcp port number that the server would listen on.

When it finally ran, it worked fine then died, then would run but not really display anything and the machine killed the connection. If it does not work for you, feel free to post back and I can try to help.

The $5 webcam http://goo.gl/ZHegH an ebay search for driverless webcam will bring up most of the cams that will work with the uvc drivers hence this tutorial applies.

Funny part is the reason for trying mjpeg-streamer was because there are claims its very light weight compared to motion, but still keeps the cpu at 70~90% clocked, same as motion, maybe more testing is needed, also not sure if multiple cam inputs are supported, which motion does allow.