WebCam: Using mjpeg streamer to stream video over HTTP

This article illustrates how stream video on web using commercials USB webcams

In the following image is visible an Aria G25 SoM wired directly to the circuitry os a Microsoft HD-3000 webcam:

This is the result obtained on a web browser. Click to see the 1:1 dimension.

We've tested some webcams that belong to different classes of cost and feature:

  • Microsoft Lifecam HD-3000
  • Microsoft Lifecam HD-5000
  • Microsoft Lifecam Cinema 720p HD webcam
  • Microsoft LifeCam Studio 1080p HD
  • Logitech Webcam C250 1.3 megapixel webcam
  • Logitech QuickCam® Sphere AF. Motorised 2-megapixel HD sensor webcam with Carl Zeiss® optics.

All these cams are compatible with the USB Video device Class (UVC) that is a standard USB device class defined by the USB Implementers Forum.

The UVC driver for Linux are available here but since the Linux 2.6.26 is included in kernel source distribution.

What we need more is mjpeg_streamer program that gets the mjpeg data from V4L2 and send it through a HTTP session.

Mjpeg_streamer automatically generates a set of html pages that illustrates different methods to stream the video over your browser. The best result comes using Google Chrome on any OS but it works well also on Firefox, Opera and IE.

The stream works well but slower also on the iPhone.

Using the Logitech QuickCam Sphere AF it is possible to control also the camera tilt an pan with the default control panel.

MJPG Streamer installation

It is possible to install MJPG streamer from the sources and compile it directly on the Acme Linux Board.

Download the sources from this link:

Save the file on the Acme board microSD then uncompress it by typing:

~# tar -xvzf mjpg-streamer.tar.gz
~# cd mjpg-streamer

Install make, libjpeg-dev and libv4l-dev libraries:

~/mjpg-streamer# apt-get update
~/mjpg-streamer# apt-get install make
~/mjpg-streamer# apt-get install libjpeg-dev
~/mjpg-streamer# apt-get install libv4l-dev

Now run the source compilation:

~/mjpg-streamer# make

After a while the mjpg-streamer executable will be ready.

Kernel > 3.11 troubleshooting

If you get this error:

.. fatal error: linux/videodev.h: No such file or directory

Create a soft link to /usr/include/linux/videodev2.h

~/mjpg-streamer# ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h

Comment also the following line in the Makefile:


If at run time it still doesn't work verify, using make menuconfig that that the USB Video Class is enabled in the Kernel :

Device Drivers  --->
    <*> Multimedia support  ---> 
        [*]   Media USB Adapters  --->
            <*>   USB Video Class (UVC)

How to use MJPG Streamer

Plug your webcam and type:

~/mjpg-streamer# dmesg
usb 1-2: new full speed USB device using at91_ohci and address 4
Linux video capture interface: v2.00
uvcvideo: Found UVC 1.00 device  (046d:0804)
input: UVC Camera (046d:0804) as /devices/platform/at91_ohci/usb1/1-2/1-2:1.0/input1
usbcore: registered new interface driver uvcvideo
USB Video Class driver (v1.0.0)
usbcore: registered new interface driver snd-usb-audio

Now run the streaming server typing:

~/mjpg-streamer# ./mjpg_streamer -i "./ -f 15 -r 640x480" -o "./ -w ./www"
MJPG Streamer Version.: 2.0
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 15
 i: Format............: MJPEG
 o: www-folder-path...: ./www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled

If you are using an Aria G25 or Terra board on full speed USB ports (Port A and B) try to get the streaming in 720p resolution by typing:

~/mjpg-streamer# ./mjpg_streamer -i "./ -f 15 -r 1280x720" -o "./ -w ./www"

A complete list of examples are available on the file in mjpg_streamer directory.

The video below shows a web video streaming using the tilt and pan controls:

Notes for Debian Lenny 5.0 users

If you are using Debian Lenny 5.0 add to the /etc/apt/sources.list file this line:

deb lenny-backports main

Related links

EUR 28.00

Microsoft Lifecam HD3000

Microsoft LifeCam HD-3000 webcam

| Product description || How to use it |

EUR 27.60

ARM9 Linux Embedded Module

Aria G25 is a small and low-cost multi-chip module that integrates:* an ARM9 @ 400Mhz CPU Atmel AT91SAM9G25* a 128MB of DDR2 RAM* 10/100 Ethernet interface* up to 3 USB 2.0 host ports* Normal temperature range version (-0° +70°)

| Product description || Flat price up to 999 pcs |

EUR 169.00

Linux embedded board for fast prototyping

TERRA is a carrier board conceived both to evaluate the Aria G25 SoM and to make prototypes or small production batches of OEM equipments using the Daisy cabling system.

| Product description | Terra catalog |

Currently this product is out of stock
The lead time is 4 weeks

EUR 139.00

FOX Board G20

FOX Board G20 is a "ready-to-run" Embedded Linux System perfect to use as a solid state WEB server or as a core engine for your embedded appliances.

A fully Open Source environment is available to customize and build your own kernel image or to develop user applications using standard GNU tools. Version with Atmel AT91SAM9G20 with 256KB of FLASH memory, 64MB of RAM and up to 16GB of microSD.

FOXG20 needs some extra accessories in order to be operative:

  • a bootable microSD with Linux OS (see DEBM2G or DEBM4G products)
  • a 5 Volt DC power source (see PS5V1A product)
  • a 3V lithium battery for internal RTC circuitry (see CH23-1220 product)

An evalution kit with all the accessories you need to get started with FOX Board G20 is available on-line on this link: COMBO-2.

| Product description |