Linux

The GNU/Linux module (prototype) is a combination of a Video4Linux2 device driver, and an executable app that will transfer the stream from the phone to the driver.

It’s assumed you are somewhat familiar with the system and how to use the Terminal. Also please keep in mind other posts on the blog are Windows oriented.

Install

1. You must first remove any old versions of the client you have. Scroll down to the “Removal” section below.

2. If you are using an older Android device, check the version of DroidCam that was installed from the play store and run the appropriate commands from below.

For DroidCam & DroidCamX version 6 and above (newest):
cd /tmp/
sudo apt-get install linux-headers-`uname -r`
bits=`getconf LONG_BIT`
wget https://www.dev47apps.com/files/600/droidcam-${bits}bit.tar.bz2
[[ ${bits} -eq 32 ]] && checksum=c8baa64b3f1e1d9b9051ece23474e58f
[[ ${bits} -eq 64 ]] && checksum=ad14437f0556d80f981d1027766afe29
echo "${checksum}  droidcam-${bits}bit.tar.bz2" | md5sum -c --
# OK?
tar xjf droidcam-${bits}bit.tar.bz2
cd droidcam-${bits}bit/
sudo ./install

For DroidCam & DroidCamX below 6: [show]

Please download one the following packages to /tmp, extract and run sudo ./install 640 480
64-bit (f937c3510615af68c007b8c72deadb14), or 32-bit (73c6b9d853a0a6ab7c6d15174450a3f1).

* If you are running the newest Linux kernel (version 4 or above) and seeing errors, make sure your installed gcc version is 4.9 or above:
uname -r # prints linux version
gcc -v # prints gcc version


3. Once everything goes without error, you can ensure the device is installed with lsmod. Look for ‘v4l2loopback_dc’.

Open up a V4L2 compatible program (VLC player, Skype, Cheese, etc) and you should see DroidCam listed as a video device.

4. Start droidcam via the Terminal, or create a launcher if you’re using gnome. You can also try droidcam-cli -h.

5. Check the connection post on how to connect. If all goes well, you should see the output in the chat application, and you’re done!

A note about USB connections: The latest version of the client will try to invoke ‘adb’ automatically, provided the executable is found via the $PATH environment variable (ie. export PATH=$PATH:/path/to/adb).
The following commands are automatically executed:
adb start-server
adb devices # Look in output for a connected device
adb forward tcp:$port tcp:$port # $port = specified port on the client

The Linux client is open source.

Update webcam resolution

You may change the webcam output resolution as follows:

1. Close any programs using the droidcam webcam. Unload the device driver:
sudo rmmod v4l2loopback_dc

2. Re-load it as follows (WIDTH and HEIGHT are numbers). :
sudo insmod /lib/modules/`uname -r`/kernel/drivers/media/video/v4l2loopback-dc.ko width=WIDTH height=HEIGHT
Recommended resolutions: 320×240, 480×360, 640×480, 960×720 or 1280×720.

3. Restart the droidcam client to reload the settings, and test it out. You can keep changing the resolution.

4. Edit the text file /etc/modprobe.d/droidcam.conf with the new options to make the change stick.

Removal

To remove the DroidCam client (or existing old version):
Close any running programs. Run one of the following (depends which version of the linux client you got)
sudo /opt/droidcam-uninstall
# OR
sudo ~/.droidcam/uninstall
  1. Francois Baret says:

    I have updated completely my Samsung phone and when I try to get back DroidcamX from Play Store I am asked to pay again. Once acquired isn’t the license valid for ever?

    • dev47 says:

      Hi,
      Yes, the purchase should be tied to your Google account. So just make sure you are using the same account on the updated system.

  2. Gary says:

    The ./install command fails. Apparently you expect me to have built my kernel. While I have done this in the past, like most Linux users, I don’t regularly do this anymore and it is a significant hurdle. Merely obtaining a copy of the kernel source isn’t sufficient.

    Firstly, is this correct: do I need to build a kernel to get the ./install script to work?

    Secondly, is there an alternative?

    I’m using an RPM based distro, so I ran ./install as root.

    • dev47 says:

      Hi Gary,
      No, you’re not building the kernel. You are building a kernel module – the webcam.
      linux-headers are just some header files and build programs, not that big, used to build the module.

    • Gary says:

      But, apparently I don’t need to have a client because a web browser will display the camera stream. I guess I just wasted some time because I didn’t click enough buttons.

  3. RonX says:

    Hi,
    according to earlier comments, DroidCam can be compiled for Raspbian.
    Unfortunetely I’m not smart enough to do that. I’m not very fimilar with Linux, so I thought someone arround here maybe knows what exactly goes wrong. Here’s the output:
    ______________________________
    src/decoder.c:592:36: warning: passing argument 2 of ‘sws_scale’ from incompatible pointer type
    sws_scale(jpg_decoder.swc, srcSlice, srcStride, 0, jpg_decoder.m_height, dstSlice, dstStride);
    ^
    In file included from src/decoder.c:28:0:
    /usr/include/libswscale/swscale.h:223:5: note: expected ‘const uint8_t * const*’ but argument is of type ‘uint8_t **’
    int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
    ^
    ~~~~~~~~~~~~~~~~~~~

    To me it looks like a compatibility problem between the compiler and libswscale. But I don’t know exactly and I neither got a clue, what I could try next. Thanks for your attention.

    • dev47 says:

      Hi,
      Looks like just a warning, no errors. And you can ignore that warning, it shouldnt cause any issues.
      Assuming no errors were output, you should have the droidcam binary ready in the same directory.

      • RonX says:

        Man… I’m such a smart boy! – It compiled fine and created DroidCam-cli right infront of my nose. *_*

        How ever, in hope that I’m not asking the next stupid question now…
        I can’t install the driver because the folder ‘build’ doesn’t exist in “/lib/modules/4.9.37-v7+”
        It exists in 4.9.35-v7+, but probably I shouldn’t just copy it over? – Thanks again!

        • dev47 says:

          No worries.
          It sounds like the installed versions of linux-headers doesnt match that of either make or another component.
          You can try listing installed packagers and filtering for both versions to see which one is what.
          On Debian, it would be ‘dpkg -l | grep 4.9.37-v7‘ and ‘4.9.35-v7‘.
          These sort of errors tend to be annoying to solve, its a matter of installing the right version. You can try upgrading whichever package is installed with 4.9.35-v7. You can also try forcing a version, example: apt-get install packagename=4.9.38-v7+".

  4. RonX says:

    Thank you. I managed to get everything compiled and installed. But “dpkg -l | grep 4.9.37-v7″ and so on, didn’t give me any results. And the availible ‘raspberrypi-linux-headers’ package via apt-get is the outdated one, I’ve got installed already. But I found the matching .deb elsewhere.

    How ever… if I connect with ‘droidcam-cli IP PORT”, everything is fine. But the droidcam binary crashs with message: MemoryAccessFailure
    The stream is shown for about 1 sec. on the android device, before that happens.

    Here’s what I did – Maybe also useful for other people:
    ========================================
    – Compiled and installed: https://github.com/libjpeg-turbo/libjpeg-turbo/archive/master.zip
    – Installed matching ‘raspberrypi-linux-headers’ from: https://www.niksula.hut.fi/~mhiienka/Rpi/linux-headers-rpi/
    – apt-get install gtk+2.0-dev liglib2.0-dev libjpeg-dev libswscale-dev
    – Edited the DroidCam ‘makefile’ to:
    LIBS = -lgthread-2.0 -l:libswscale.a -l:libavutil.a -l:/../../opt/libjpeg-turbo/lib32/libturbojpeg.a
    – make
    – make cli
    – ./install
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    But unfortunately it looks like I should do something different?! xD

    • dev47 says:

      hmm.. -l:/../../opt/libjpeg-turbo/lib32/libturbojpeg.a looks a little fishy, especially that ‘/’ at the very beginning.
      I’m not sure why you needed to install ‘libjpeg-dev’, it could be interfering.
      Make sure the makefile is pointing to the right directory for libturbojpeg.a; and if its complaining about header files at compile time – see if there is a ‘include’ directory under opt/libjpeg-turbo/, if so add a ‘-I /opt/libjpeg-turbo/include’ to the CC= line.

      • RonX says:

        First off, sorry for not hitting the reply button above. Maybe this schould be merged. Maybe even to the earlier conversation about this, on page 2.

        That path thing… strange behaviour indeed. But it seems to work, because it doesn’t compile, if the file is not found. It actually doesn’t matter if its ‘-l:../..’ or ‘-l:/../..’ – But I have to point backwards from ‘Pi/Desktop/DroidCam’ to ‘/Pi’ by ‘../..’ to get it compiled.

        I installed libjpeg-dev because jpeglib.h was missing. I completely removed it and now it needs your described CC= line to compile. But the droidcam process still terminates immediatelly if I connect. No matter if adb, wifi or server mode. I think it’s probably related to the strange backward path thing. But I got no idea why it is the way it is and why the CC= line doesn’t need the ../..

        • dev47 says:

          Are you compiling on a separate machine/system, or the Pi itself?
          I’m not sure what else I could suggest.. at this point I’d start adding some print lines into the client code and see where exactly it crashes.
          In src/common.h you’ll see ‘#define dbgprint voidprint’ if you change that to ‘#define dbgprint errprint’, then add a bunch of dbgprint("blah"); in decoder.c (which is where I’m guessing the crash is coming from) to try and figure out whatsup.
          Also, does ‘-l:/opt/libjpeg-turbo/lib32/libturbojpeg.a’ not work? Because I see you also have ‘-I /opt/libjpeg-turbo/include’ and thats works I assume.

Leave a Reply

Your email address will not be published. Required fields are marked *

captcha

Follow @dev47apps