Hass.io with USB Webcam

Hello!

I am running hass.io on a Raspberry Pi 3 and would like to use a standard USB-Webcam.
The webcam is recognized in Hass.io / System / Hardware:

input:
    Microsoft® LifeCam HD-3000: Mi

I know that the plugin motionEye does currently not support local USB Webcams, but is there any way of using this device with a hass.io installation? Maybe via an installation of a webcam-server via the SSH console that forwards the pictures to motionEye? Would that be possible? Or is there another plugin for such cases?

Does anyone have experience with this?

Thank you!

1 Like

Hi

Install motion (https://motion-project.github.io/)
After that you can reach your wecam(s) like normal mjpeg cameras (https://www.home-assistant.io/integrations/mjpeg/).

I use my USB webcams this way.

T.

Hello!

Thanks for your reply! How did you install motion? Are you running hass.io on a “normal” Linux?
I am asking because I am running the standalone hass.io image for the Raspberry Pi, and as far as I know, I can only install the hass.io addons there.

Yes, I have hassio on Debian server.

Hi

I migrated recently from Motion to mjpg-streamer. It less resource hungry. I have 2 USB webcams on the HASS server. With Motion the server sometimes was very slow and unreacheable. Memory and CPU consuption was not high… :angry: So I decided to try something else.

Small guide for the mjpg-streamer

Check webcam availability and device name:

sudo apt install v4l-utils
v4l2-ctl --list-devices

Info from the /dev/video0 device (to get the max resolution):

v4l2-ctl --device=/dev/video0 --all

Be careful:

Install:

sudo apt-get install cmake libjpeg62-turbo-dev
sudo apt-get install gcc g++

download: https://github.com/jacksonliam/mjpg-streamer/archive/master.zip
extract it
go to the folder where are the extracted files

cd mjpg-streamer-master/mjpg-streamer-experimental/
make
sudo make install

Usage in terminal (my example):

mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 1920x1080 -f 30 -q 50 -n" -o "output_http.so -p 8080 -n"

Reach from browser:
http://<hostname>:8080/?action=stream

HASS config:

- platform: mjpeg
  name: Cam
  mjpeg_url: http://<hostname>:8080/?action=stream

Options for the input:

 [-d | --device ].......: video device to open (your camera)
 [-r | --resolution ]...: the resolution of the video device,
                          can be one of the following strings:
                          QSIF QCIF CGA QVGA CIF VGA
                          SVGA XGA SXGA
                          or a custom value like the following
                          example: 640x480
 [-f | --fps ]..........: frames per second
 [-y | --yuv ]..........: enable YUYV format and disable MJPEG mode
 [-q | --quality ]......: JPEG compression quality in percent
                          (activates YUYV format, disables MJPEG)
 [-m | --minimum_size ].: drop frames smaller then this limit, useful
                          if the webcam produces small-sized garbage frames
                          may happen under low light conditions
 [-n | --no_dynctrl ]...: do not initalize dynctrls of Linux-UVC driver
 [-l | --led ]..........: switch the LED "on", "off", let it "blink" or leave
                          it up to the driver using the value "auto

Options for the output:

[-w | --www ]...........: folder that contains webpages in 
                          flat hierarchy (no subfolders)
[-p | --port ]..........: TCP port for this HTTP server
[-c | --credentials ]...: ask for "username:password" on connect
[-n | --nocommands ]....: disable execution of commands

Cheers
T

I’m not so familiar about the HassOS but it uses docker. You can get to the shell and run docker commands or install Portainer addon. After you can install mjpeg-streamer image to docker.
Google it: https://www.google.com/search?q=docker+mjpg-streamer

ailispaw/mjpg-streamer looks promising to me. Maybe I’ll move to doker from shell too.

1 day later…

Winner is:

sudo docker run \
    --device /dev/video0 \
    --entrypoint mjpg_streamer \
    -p 8080:8080 \
    kvaps/mjpg-streamer \
    -i "/usr/lib64/input_uvc.so -d /dev/video0 -r 1280x720 -f 30 -q 50 -n" \
    -o "/usr/lib64/output_http.so -p 8080 -n"

Cool I can handle it from Docker.

I think this is the answer for your question…

T

Hello, I install Home Assistant OS on raspberry pi 3 and wished to do the same as you. I’ve browse the community and can’t find to integrate usb webcam to home assistant. Do you have any idea where should i start? Thanks

Hello Maulana,

you are lucky - the maintainer just released an updated two days ago which finally makes it possible to use USB Webcams! :slight_smile:
I’ve just tried it and it works like a charm!

I am using the latest version of HomeAssistant and the latest version of the Addon motionEye

You should find the addon under “Supervisor” - Addon-Store under the Community Addons.

I also used the latest version of home assistant and motion eye. So it just recently updated, that’s why I can’t find any walkthrough. Do you mind share to me how to use USB webcam? Thanks.

Well, I don’t know at which point you have problems…

After installing the plugin, you have to logon with username “admin” and leave the password field empty.

While adding a camera, I have selected Local V4L2 camera as the “Camera Type”, and in the dropdown menu next to “Camera”, I have selected my camera (it’s there twice, but only the first one was working for me):

grafik

After confirming with OK, I was directly able to see the video - I only had to adjust the framerate and resolution to the camera / my needs.

Hope this helps

I successfully login after installing the plugin. I missed the second step, because i don’t know what camera type that i should add. Thanks to you now i know that my USB camera is in V4L2 camera. add_usb_camera
Thanks a lot :slight_smile: Now i want to display the live streaming on the lovelace user interface. Any idea how?

1 Like

Has anyone tried this with home assistant running in PROXMOX (virtualization)? In proxmox I have passed my USB camera through to the home assistant server. But it does nog show up as a camera under Loval V4L2 Camera in motion eye.

I do notice that my usb camera also does not show up under the hardware tab in home assistant (supervisor -> system -> hardware).

This issue is fixed in with an update to HassOS 3.13.

Hello, Idk why, but my webcam doesn’t seem to be detected, all I get is those “bcm2835-codec-decode”… Shouldn’t my webcam be automatically detected? Thank you,