[root tip] Get DroidCam working on Manjaro

Difficulty: ★★☆☆☆

Droidcam

A demonstration on how to build and install droidcam.

Droidcam - GNU/Linux client

A tool for using your android device as a wireless/usb webcam

Problems

Judging from the a search for droidcam (archived forum) it appears Manjaro users are having a difficult time getting this into a working state.

Droidcam on AUR

Judging from some comments on the AUR page on non-versioned package source it seems the package source is not versioned but that may have changed or will change.

When you need to rebuild the droidcam package it is important to get the latest source so you should make sure your don’t have sources in the build folder or cached by an AUR helper.

The comments track is filled with issues not only with relation to the build but also sound issues.

The maintainer also states that Manjaro is not supported.

We will take the sound issues later - first we take a look at getting your android device camera connected.

Your Android device

Before you even think of getting your computer to connect you must install the DroidCam application on your android device.

Use the Play Store to install the DroidCam App.

My device is a rooted Huawei Nexus 6P using a crDroid Android 10 without any Google related stuff (and I mean nothing at all).

There is several possible ways to get hold of the apk - I downloaded the apk, renamed it and installed it using adb debug

adb install droidcam-6.7.10.apk

It is necessary to setup the DroidCam and to start the App to be able to connect to it from your computer.

Your Manjaro system

My Manjaro system is on unstable branch and using kernel 5.7.4 using Openbox window manager.

The maintainer of the PKGBUILD states that only makepkg is supported - so let’s use it to build the package.

Update your system and install the necessary build tools

sudo pacman -Syu --needed git base-devel

Next thing is to get hold of the PKGBUILD. Open a terminal and clone the repo

$ git clone https://aur.archlinux.org/droidcam              
Cloning into 'droidcam'...
remote: Enumerating objects: 110, done.
remote: Counting objects: 100% (110/110), done.
remote: Compressing objects: 100% (98/98), done.
remote: Total 110 (delta 11), reused 109 (delta 11), pack-reused 0
Receiving objects: 100% (110/110), 43.37 KiB | 2.55 MiB/s, done.
Resolving deltas: 100% (11/11), done.

Navigate into the folder and list the content

$ droidcam                                
$ ls -A
.git droidcam.conf  droidcam.desktop  PKGBUILD

What we are interested in is the PKGBUILD as it is a good habit to verify the content

droidcam/PKGBUILD
$ cat PKGBUILD 
# Maintainer: AwesomeHaircut <jesusbalbastro at gmail com>
# Maintainer: Mateusz Gozdek <mgozdekof@gmail.com>
# Contributor: Rein Fernhout <public@reinfernhout.xyz>
# Past Contributor: James An <james@jamesan.ca>

pkgname=droidcam
pkgver=1.3
pkgrel=1
epoch=1
pkgdesc='A tool for using your android device as a wireless/usb webcam'
arch=('x86_64')
url="https://github.com/aramg/${pkgname}"
license=('GPL')
depends=('v4l2loopback-dc-dkms' 'alsa-lib' 'libjpeg-turbo' 'ffmpeg')
makedepends=('gtk3')
optdepends=('gtk3: use GUI version in addition to CLI interface' )

source=("${pkgname}.desktop"
        "${pkgname}-${pkgver}.zip::${url}/archive/v${pkgver}.zip"
        "${pkgname}.conf"
)

sha512sums=('72d21aa2d7eecc9bb070aaf7059a671246feb22f9c39b934a5463a4839f9347050de00754e5031dbc44f78eb2731f58f0cd2fcf781bc241f6fbd1abb4308b7ee'
            'c783b62c530c521aa7f047073efe74b57f28fbadbd097dca595fb582820566aedd03c6e92d2f24d9ff84dceed8ab51955ad77e80481ebfb6e30423425f8f2953'
            'ea457b46a2fc9f1a3ea8e99f2cd0771a587cff89f42335fdaf55988dda0376a1fea73b660174c9f1906a304bace68bffec30b70b20dafc05ebae8854d9aadb13')

build() {
  cd ${pkgname}-${pkgver}/linux

  # All JPEG* parameters are needed to use shared version of libturbojpeg instead of
  # static one.
  make JPEG_DIR="" JPEG_INCLUDE="" JPEG_LIB="" JPEG=$(pkg-config --libs --cflags libturbojpeg)
}

package() {
  pushd ${pkgname}-${pkgver}/linux

  # Install droidcam program files
  install -Dm755 "${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
  install -Dm755 "${pkgname}-cli" "${pkgdir}/usr/bin/${pkgname}-cli"
  install -Dm644 icon2.png "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
  install -Dm644 "../../${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
  install -Dm644 "../../${pkgname}.conf" "${pkgdir}/etc/modules-load.d/droidcam.conf"
  install -Dm644 README.md "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

We find the expected stuff - a list of dependencies - and note that we have a dkms dependecy - and from the package() function it is worth noting that we get a new configuration loading the v4l modules required to connect to a live camera.

The dkms dependency is tricky because it usually requires kernel headers to be installed for your kernel. While Arch only has clearly distinctive kernels with only one version - Manjaro has several versions and every version has a complimentary header package.

So to be able to build droidcam you need to ensure the headers are installed for all of your kernels - otherwise the droidcam app will not build and ultimately not work.

List your installed kernels - example from my system

$ mhwd-kernel -li  
Currently running: 5.7.4-1-MANJARO (linux57)
The following kernels are installed in your system:
   * linux56
   * linux57

With this info - please use the output from your system - install the kernel headers

sudo pacman -Syu linux56-headers linux57-headers

Now we are ready to build and install the package and the dependencies. When the build is done - you will be asked to authorize the package installation.

makepkg -is
$ makepkg -is
==> Making package: droidcam 1:1.3-1 (fre 19 jun 2020 12:36:46 CEST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found droidcam.desktop
  -> Downloading droidcam-1.3.zip...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   117  100   117    0     0   1218      0 --:--:-- --:--:-- --:--:--  1218
100 91207    0 91207    0     0   126k      0 --:--:-- --:--:-- --:--:--  126k
  -> Found droidcam.conf
==> Validating source files with sha512sums...
    droidcam.desktop ... Passed
    droidcam-1.3.zip ... Passed
    droidcam.conf ... Passed
==> Extracting sources...
  -> Extracting droidcam-1.3.zip with bsdtar
...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: droidcam 1:1.3-1 (fre 19 jun 2020 12:36:48 CEST)
==> Installing package droidcam with pacman -U...
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) droidcam-1:1.3-1

Total Installed Size:  0,12 MiB

:: Proceed with installation? [Y/n] 
...
:: Running post-transaction hooks...
(1/2) Arming ConditionNeedsUpdate...
(2/2) Updating the desktop file MIME type cache...

You should get a similar output and if you don’t you have inconsistencies within your system.

I can’t say what it might be - but suffice to say - as the time of writing this guide - the droidcam package builds without hickups

Starting the DroidCam app

The app is depending on the correct v4l modules to be loaded by the kernel. If the kernel is updated but the system not restarted - there will be a mismatch between the kernel and modules which will make the application fail.

Better safe than sorry - reboot your system - or manually load the required modules which are described in droidcam.conf. Manually loading the modules do not guarantee droidcam will work - your best shot is still a restart of your system.

$ cat droidcam.conf 
videodev
v4l2loopback-dc
$ sudo modprobe videodev v4l2loopback-dc

WiFi/LAN

To connect using WiFi you must ensure your phone is on the same local network as your computer. When you start DroidCam on your device it will display the IP address to connect to.

Depending on what you want to do

Connect using a browser

  • http://<phoneip>:4747/
  • http://<phoneip>:4747/video

Sound

@electron has provided the following info on getting sound working

In the droidcam window locate the status indicating client version and devices. As an example audio device could be hw:0,1,0.

While droidcam is running execute (replace $HW with your hardware id)

$ pacmd load-module module-alsa-source device=$HW

This will load the device to pulse audio. now you can goto your Sound settings and change the microphone.

As of 2020-06-02T12:13:00Z sound support is an ongoing issue.

Another comment in the thread mentions an install-sound script?

Forum issues list

9 Likes

Thank man!!! work very well!

im still confused, i am a newbie with linux, can you explain what (master) is? i copied and pasted it in the terminal but doesnt work

It is just a terminal extension to show default branch name of git. Don‘t copy that. Start copying after ➜ droidcam git:(master) .

Thank god for custom ROMs!

Thanks for the guide! Worked like a charm (moto e5, manjardo kde)

1 Like

Installing headers ( MUST! for droidcam )

List out the kernels in your Manjaro system

$ mhwd-kernel -li
Currently running: 5.9.10-1-MANJARO (linux59)
The following kernels are installed in your system:

  • linux54
  • linux59

Install the headers for your respective kernel via pamac-gtk or with terminal command:

$ pamac install linux54-headers linux59-headers

give your system a reboot.

Installing Droidcam - Manjaro

Build droicam with the command:

$ pamac build droidcam

this command builds droidcam from AUR
give your system a reboot to get the modules load.

Installing Droidcam - Android

Download ‘droidcam’ app from Playstore or any source you know (My device is Galaxy J7 Prime)
If you are using droidcam via USB, enable ‘USB debugging’ in developer option.

Using Droidcam, in USB

Droidcam is now available in your application menu.(both manjaro & android :innocent:)

  • Open droidcam in Android and in Manjaro
  • Enable Video, Audio and click Connect
  • goto 127.0.0.1:4747 / webcam test website / any camera app to check your camera (note: Gnome Cheese didnt work)
    Screenshot from 2020-11-26 08-01-52

WIFI/LAN

I assume that your phone and PC is connected to the same network. open droidcam in Manjaro and phone. click ‘Connect’ then
goto <phone-ip>:4747 / webcam test website / any camera app to test it out.

For Audio(microphone) to work :

In the above image, you can see droidcam audio device as hw:0,1,0 (may change for others).
While droidcam is running, execute:

$ pacmd load-module module-alsa-source device=hw:0,1,0

This will load the device to pulse audio. now you can goto your Sound settings and change the microphone.

2 Likes

You can also do this with a little snippet automatically:

pamac install $(ls /boot | awk -F "-" '/^linux/ { print $1"-headers" }')
1 Like

Nothing is required, if you install headers or a module for a kernel, pamac auto install them for other installed kernels.
And if you install a new kernel, pamac auto install headers and modules already installed for other kernels.

Duplicate of already existing guide

@electron
Good work figuring out how to get audio working - I suggest moving the audio instruction to existing guide.

On a note on using pamac.
The AUR maintainer has clearly stated that using an AUR helper to install droidcam is not supported.

The reasons are

  • the linux header requirement
  • upstream does not version the zip
    • when AUR helpers caches the source - you may not get the correct release