Video recorder and streamer with USB camera

view/record what is viewed inside and/or around the RV at parking lot or while driving


Main components:
- USB camera,
- any single-board computer, one of the Cubietruck clones in this case,
- the camper's NAS,
- the camper’s router.

Since the USB cameras do not have an RTSP streamer and they use a resource-intensive USB port, this is the worst use case for the camera. Wired IP camera is better, wireless IP camera is worse, but USB camera is the worst in between.

But it still works and this case is described here.

Streaming from the USB-camera will be available on the local network of the camper through the IP-address of a single-board computer. Video recording (archive) will be stored in camper's NAS storage and will be available in the camper’s network.

Theoretically, it is possible to control more than one USB camera on one single-board computer, but not each processor of this computer can do this normal.

In this case, one Cubietruck clone was used with the Armbian OS (Ubuntu version), flashed to a 4GB SD card with Etcher.
The Cubietruck processor was with a good cooling solution.

The USB camera was not connected to Cubietruck at the beginning of setup. All settings were made via Windows PC. In some cases will need to switch off the PC firewall while settings.

When Armbian started, the password for the root user was changed and another normal user was made. Once Armbian is configured to use a Wi-Fi of the camper’s router, it will be available in the PC terminal via PuTTY over IP via 22 port. The IP address can be found in the web interface of the camper’s router.

Then was changed the hostname of Cubietruck:

nano /etc/hostname

In the opened file "cubieboard" was changed to "CA-Host1". Then:

Ctrl+O, Enter, Ctrl+X

nano /etc/hosts

In the opened file "cubieboard" also was changed to "CA-Host1". Then:

Ctrl+O, Enter, Ctrl+X


Cubietruck has been rebooted. There was a root login after a while.

This commands were entered from PC via PuTTY terminal for a long life of the SD card:

swapoff -a

Then cmake was installed:


tar xzf cmake-3.13.3.tar.gz

cd cmake-3.13.3

./configure --prefix=/opt/cmake


make install

rm cmake-3.13.3.tar.gz


nano  /etc/environment

In the opened file string:


was changed to string:


that is, the substring "/opt/cmake/bin:" was added for the PATH environment variable. Then the commands were entered:

Ctrl+O, Enter, Ctrl+X


After rebooting and logging in to root, the MJPG-Streamer and FFmpeg packages were installed:

apt-get install libjpeg8-dev

apt-get install v4l-utils

cd /tmp

git clone

cd mjpg-streamer/mjpg-streamer-experimental


make install


apt-get update

apt-get install ffmpeg

It was then authorized as the root user for the camper's NAS via PuTTY over the NAS IP at 22 port. And the commands were entered:

nano /etc/exports

In the opened file, the full path of access to the camper's NAS shared folder (in this case, CA-NAS-shfld) from any NFS client within the camper's network was found. In this case, it was /export/CA-NAS-shfld.

In the camper's NAS shared folder, it was necessary to make a folder to archive video from the USB camera. Here the camera/folder name was inner_cam_01:


mkdir /export/CA-NAS-shfld/inner_cam_01

Then the size of the folder for the video archive from the USB-camera to 10000 MB was limited. To do this, the crontab file was opened and added to its end:

crontab -e

# in this case, "Joe's Own Editor" was opened 

# the following line gives the command every 6 minutes to delete the oldest files in the folder when the folder size exceeds 10000 MB

*/6 * * * * while [ $(du -sm /export/CA-NAS-shfld/inner_cam_01| cut -f1) -gt 10000 ]; do rm -f /export/CA-NAS-shfld/inner_cam_01/"$(ls -1c /export/CA-NAS-shfld/inner_cam_01/ | tail -n1)";done > /dev/null 2>&1

# and at least one empty line should be at the end of the file!

Ctrl+K, Ctrl+X

Then in the Cubietruck using PuTTY was prepared by mounting the NAS folder for archive video from a USB camera:

apt-get install nfs-common

mkdir /mnt/nvr

echo " /mnt/nvr nfs rw,async,soft,timeo=10,intr,nolock 0 0" >> /etc/fstab

Where: is the IP address of the camper's NAS,

/export/CA-NAS-shfld/inner_cam_01 is the camper's NAS shared folder for USB camera video archive, which is described here above.

Then all connected USB cameras were listed:

ls /dev/video*

The USB camera was then connected to Cubietruck. Once again, all connected USB devices were listed:

ls /dev/video*

One new line that appeared in the second list was the alias of the wired USB camera. In this case it was /dev/video0.

Then the parameters of the USB camera were determined:

v4l2-ctl -d /dev/video0 --all

These camera parameters should be noted:

Width/Height : 1280/720

Pixel Format : 'MJPG'

Frames per second: 25.000 (25/1)

These settings are best used and do not make any other changes to minimize CPU usage.

Then the following commands were made. Since crontab was first launched in Cubietruck, the issue of editor selection was raised. Nano was selected:

chmod ugo+rwx /dev/video*

crontab -e

1, Enter

Then were added to the end of the open file:

@reboot sleep 110 && /usr/local/bin/mjpg_streamer -i " -r 1280x720 -d /dev/video0 -f 25 -q 80" -o " -p 8080 -w /usr/local/share/mjpg-streamer/www" > /dev/null 2>&1

@reboot sleep 110 && mount /mnt/nvr > /dev/null 2>&1

*/2 * * * * ffmpeg -f mjpeg -r 5 -i "http://localhost:8080/?action=stream" -t 120 -c:v copy /mnt/nvr/`date +\%Y\%m\%d_\%H\%M\%S`.avi > /dev/null 2>&1

@hourly killall mjpg_streamer > /dev/null 2>&1

@hourly sleep 60 && /usr/local/bin/mjpg_streamer -i " -r 1280x720 -d /dev/video0 -f 25 -q 80" -o " -p 8080 -w /usr/local/share/mjpg-streamer/www" > /dev/null 2>&1

# and at least one empty line should be at the end of the file!

Ctrl+O, Enter, Ctrl+X


Approximately 2 minutes after the download, streaming from the USB camera was available at via browser or at via VLC.

Where is the IP Cubietruck (CA-Host1) in the camper’s network.

The streaming archive from the USB camera will be stored on the camper's NAS in the CA-NAS-shfld/inner_cam_01 shared folder, fragmented into files lasting 2 min each.

The other variant for archiving a video from the USB camera is listen http of Cubietruck on the camper's NAS side by ffmpeg like ordinary IP-camera (but with http protocol). But a static IP is needed for this for Cubietruck (CA-Host1). What the method is best - is philosophy.

A software you can load from this site is free for a non-commercial use except for components for which their owners declared their own rights. Can be limited by local laws. No of your data will be collected with a software you can load from this site.

Subscribe for updates.

Start a free site - Check this