The following page will show how to build the drivers to run a USB webcam on Ubuntu 16.04 for ESPRESSObin to stream video output to your browser. A list of UVC-compliant devices can be found here.
To build webcam drivers we need to select necessary options and modules in kernel configuration. Similarly to how we did in Ubuntu - initial network configuration, we will be manually selecting the configuration from menuconfig.
To launch make menuconfig to manually select the needed options:
espressobin@buildserver:~/kernel/4.4.8$ make menuconfig
Here we will select * the following in kernel menuconfig:
Device Drivers ---> <*> Multimedia Support ---> [*] Cameras/video grabbers support [*] Media USB Adapters ---> <*> USB Video Class (UVC)
After all these options have been selected, save your configuration and exit the menuconfig. Now we can make a new kernel image using our newly made .config file:
espressobin@buildserver:~/kernel/4.4.8$ make -j4
Now we need to transfer the new kernel images to a microSD card containing Ubuntu file system. Insert the SD card in your laptop (listed here as /dev/sdb1) and mount it (here we will mount it to /mnt/sdcard):
espressobin@buildserver:/$ sudo mount /dev/sdb1 /mnt/sdcard espressobin@buildserver:/$ cd /mnt/sdcard espressobin@buildserver:/mnt/sdcard$ sudo cp /home/espressobin/kernel/4.4.8/arch/arm64/boot/Image boot/ espressobin@buildserver:/mnt/sdcard$ sudo cp /home/espressobin/kernel/4.4.8/arch/arm64/boot/dts/marvell/armada-3720-community.dtb boot/
and boot from SD card as shown in Boot from removable storage - Ubuntu.
Once in Ubuntu 16.04 console, update and install necessary packages:
root@localhost:~# apt-get update root@localhost:~# sudo apt-get install build-essential libjpeg-dev imagemagick subversion libv4l-dev cmake git
Make a directory (we will name it simply webcam) where you will clone a repository containing the mjpg-streamer package:
root@localhost:~# mkdir webcam && cd webcam root@localhost:~/webcam# git clone https://github.com/jacksonliam/mjpg-streamer root@localhost:~/webcam# cd mjpg-streamer/mjpg-streamer-experimental root@localhost:/webcam/mjpg-streamer/mjpg-streamer-experimental# make root@localhost:/webcam/mjpg-streamer/mjpg-streamer-experimental# sudo make install
Finally, we make a script file, e.g stream.sh:
root@localhost:~# vi stream.sh
where we will run the webcam and stream the footage:
#!/bin/bash set -x #start Video Camera Streamer cd webcam/mjpg-streamer/mjpg-streamer-experimental ./start.sh &
of course, make the script executable and run it with:
root@localhost:~# chmod +x stream.sh root@localhost:~# ./stream.sh
and your webcam footage should start streaming. Access the stream via web browser by typing http://ESPRESSObin_IP_address:8080/?action=stream in URL where ESPRESSObin_IP_address is the IP address of our bridged interface (bro in our case) as set up in Ubuntu - initial network configuration:
If you want to modify characteristics of the stream such as resolution or framerate, there are options listed out in home/espressobin/webcam/mjpg-streamer/mjpg-streamer-experimental/start.sh.
For example, by default the start script will be executing line 30:
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"
If you want to specity the the resolution and frame rate, based on the example given further below in the script, you change the above line to:
./mjpg_streamer -i "./input_uvc.so -r 640x480 -f 60" -o "./output_http.so -w ./www"