Setting up an (integrated) webcam to use in Ubuntu inside VirtualBox can be a tough nut to crack. However, with this guide, it should only take you a couple of minutes.
If you’re running Microsft Windows as your host operating system (OS), open an elevated command prompt (right click on cmd and run as administrator). Furthermore, please make sure that you can access VBoxManage. This is the tool that comes with Oracle VirtualBox that allows you to control your VirtualBox image from the command line of your host OS. If you cannot access it and you get the following error, please follow this short guide.
‘VBoxManage’ is not recognized as an internal or external command, operable program or batch file.
If the VBoxManage command is properly working, type the following command to list all the webcam devices. If you don’t see any errors, please scroll down to the area below the horizontal line.
VBoxManage list webcams
However, if you thought this would work properly but instead got the following error, please download the VM VirtualBox Extension Pack and install it on your computer. Make sure to turn off your VM.
VBoxManage.exe: error: No extension pack by the name 'Oracle VM VirtualBox Extension Pack' was found.
If you run into the following error, please follow the steps below the image.
- Browse to the folder where you installed VirtualBox. The default folder is ‘C:\Program Files\Oracle\VirtualBox’.
- Next, right click on the folder named ‘ExtensionPacks’ and go to the tab Security.
- Click Edit
- In the list, select Users (LAPTOPNAME/Users)
- Give it Full Control
- Rerun the installer
- In your elevated command prompt, run the following command again:
VBoxManage list webcams
You should see an output like this. The thing I hid from you is the directory to where my integrated webcam is installed (it’s very long).
Finally, start up your VM and run the following command, where you replace the image name and the path to the webcam with your specific values. Tips:
- If the directory name is long, you can copy from your cmd using control+C.
- If your directory contains spaces or weird characters, wrap them in double quotes.
VBoxManage controlvm <image_name> webcam attach <path_to_webcam>
Congratulations, you can now use your webcam in your virtual machine!
What do you do if you have a macOS host machine.
Hi Daniel, I literally haven’t touched a Mac in years. So I can’t help you with that one.
Sincerely, Roel.
What do I do if I want to do the opposite? (Win7 VM on a Linux host)
Works the same tips. check in your linux that those packages are installed
virtualbox
virtualbox-ext-pack
Hi! I followed your tutorial from start to finish but I still get this weird error:
VBoxManage.exe: error: Code E_FAIL (0x80004005) – Unspecified error (extended info not available)
VBoxManage.exe: error: Context: “WebcamAttach(path.raw(), settings.raw())” at line 2150 of file VBoxManageControlVM.cpp
I am using Windows 10 host machine with Ubuntu 20.04.1 as my Virtual OS. Also, I have only 1 webcam. Could this be the issue?
Hey man
I’m not an expert on these things myself.
I’ve found some threads that point in the same direction.
https://github.com/docker/toolbox/issues/360
Good luck
Roel
Same problem here!
What tto do if I wnat to use the camera on my MacOS Vrtual Machine in virtual box? the hst is Windows on Dell