1

I would use a USB webcam with Motion software, installed in Ubuntu on my Windows PC (WSL2 ) But when I started Motion as a service and i check on browser at the address [LOCALHOLST:port 8080 or 8081 ] it appears the Motion interface but never has been detected my webcam. Always It is showed a gray screen, for the MyCam1 option, with written at the top on the left "UNABLE TO OPEN VIDEO DEVICE".

I tried many types of configurations in the camera1-dist.conf and motion.conf files, but unfortunately they still doesn't work

Someone who could suggest me what type of configurations and in wich file, do I have to use to detected a USB webcam with Motion software ?

Thank you in advance.

Hi, many thanks your indications has been very useful! I have followed all the steps and I have attached the webcam to my Ubuntu distribution and now Ubuntu 'lsusb' comand gives the following output

root@LAPTOP-5OFK2AK7:/home/daniele# lsusb

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Bus 001 Device 002: ID 3443:950a SHENZHEN AONI ELECTRONIC CO.,LTD NexiGo N950P 4K Webcam

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Unfortunately it still doesn't work..Motion still showes a grey screen and the UNABLE TO OPEN VIDEO DEVICE..

I think now the problem is in the camera1-dist.conf file. I'd like to set the webcam in localhost:8080 (port) or ( 8081 ) but i don't understand, it still doesn't work what and where I have to write in this camera1-dist.conf file

This config file was generated by motion 4.2.2

###########################################################

Configuration options specific to camera 1

############################################################

User defined name for the camera.

camera_name MyCam1

Numeric identifier for the camera.

camera_id 101

The full URL of the network camera stream.

netcam_url http://127.0.0.1:8080

Image width in pixels.

width 1280

Image height in pixels.

height 720

Text to be overlayed in the lower left corner of images

text_left CAMERA 1

File name(without extension) for movies relative to target directory

movie_filename CAM01_%t-%v-%Y%m%d%H%M%S

3
  • You have to make sure first that the system recognizes it. After plugging it in, do an `lsusb' and check the end of 'sudo dmesg'. You can then add the relevant output to your question. Apr 15 at 21:50
  • Add yourself to the video group sudo adduser $USER video, then logout and login. Group memberships are set up at login time.
    – waltinator
    Apr 15 at 23:40
  • Hi I have already add my user to the video group, but it still doesn't work.. The problem is that Motion doesn't recognize the webcam USB neither with the V4l2 drivers.. Thanks
    – DanielePP
    Apr 16 at 9:25

1 Answer 1

0

Because you are using WSL2, the host OS (i.e. Windows) is currently managing the webcam with its own drivers.

To allow a program running within the WSL2 instance to access an USB device like a webcam, you must tell Windows to turn over the control of that USB device to WSL2.

Source: https://devblogs.microsoft.com/commandline/connecting-usb-devices-to-wsl/

You'll need WSL2 with Linux kernel version 5.10.60.1 or later.

You'll also need to have a recent version of usbipd-win installed in Windows. You can find it here.

Within the WSL2, you'll need to install the USB/IP user-space tools and a database of USB hardware identifiers. On Ubuntu 20.04 LTS, this would be:

sudo apt install linux-tools-5.4.0-77-generic hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/5.4.0-77-generic/usbip 20

Note that the 5.4.0-77-generic part may vary if you are using a different distribution or kernel version.

To see the available USB devices and their bus IDs, open a command prompt as Administrator and enter this command:

usbipd wsl list

Find the bus ID of the USB device you wish to use within WSL2, and enter this command in the Administrator command prompt:

usbipd wsl attach --busid <bus ID>

This will apparently cause the WSL to prompt for a password, to run a sudo command. After this, the USB device will be visible in the WSL2 lsusb output, and available to the WSL2 applications (and, as a consequence, not available to native Windows applications).

Once you're done using the device in WSL2, you can either physically unplug it, or return it to Windows by running this command in the administrator command prompt:

usbipd wsl detach --busid <bus ID>
2
  • Hi, thanks very much for your helpful indications! I have followed the steps, but unfortunately It still doesn't work on Motion, still with the usb webcam now attached to Ubuntu.. I putted the output aboove
    – DanielePP
    Apr 16 at 22:24
  • Hi, after I have detached the webcam from Ubuntu, WSL ( and also Windows ) doesn't recognized anymore the webcam in usbipd wsl list ( but still in windows devices manager the webcam has disappeared ), still after reboot..
    – DanielePP
    Apr 17 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.