You are not logged in.

#1 2016-02-19 16:19:19

TriforceOfKirby
Member
Registered: 2016-01-26
Posts: 16

[SOLVED] Can I use my Android phone's camera as a webcam?

I'm in need of a webcam and rather than buying one I'm wondering if I can just use my phone's built-in camera. I have a Nexus 5X running Android 6.0.1. I've tried using the IP Webcam app along with this script, but the script didn't appear to work; I could view the stream fine in browser though.

Last edited by TriforceOfKirby (2016-02-26 00:19:45)

Offline

#2 2016-02-19 16:49:12

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 12,403
Website

Re: [SOLVED] Can I use my Android phone's camera as a webcam?

I haven't looked at the script, so I have no idea what it is supposed to do, but 'doesn't appear to work' is not helpful. How are you calling the script? What output (if any) is displayed? Does the script have a verbose mode?

Mod note :moving to NC.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2016-02-19 19:54:50

TriforceOfKirby
Member
Registered: 2016-01-26
Posts: 16

Re: [SOLVED] Can I use my Android phone's camera as a webcam?

Oh sorry, here's the output when I try to run it from a terminal:

$ ./prepare-videochat.sh
(standard_in) 1: syntax error
./prepare-videochat.sh: line 219: [: too many arguments
(standard_in) 1: syntax error
./prepare-videochat.sh: line 220: [: too many arguments
./prepare-videochat.sh: line 272: [: =: unary operator expected
./prepare-videochat.sh: line 272: [: =: unary operator expected
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
error: protocol fault (couldn't read status length): Success
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
error: protocol fault (couldn't read status length): Success
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
error: protocol fault (couldn't read status length): Success
Failure: Module initialization failed

The script is supposed to make the device recognized as a regular webcam.

Last edited by TriforceOfKirby (2016-02-19 19:57:15)

Offline

#4 2016-02-19 21:22:45

smirky
Member
From: Bulgaria
Registered: 2013-02-23
Posts: 277
Website

Re: [SOLVED] Can I use my Android phone's camera as a webcam?

Yes, you can. I used to do that before. For the purpose I used droidcam:

Linux client:
https://aur.archlinux.org/packages/droidcam/

Play Store client:
https://play.google.com/store/apps/deta … s.droidcam

It should work with wireless and usb, although I mostly used it with USB.
I haven't played with it from a long time, but it worked.


Personal spot  ::  https://www.smirky.net/  ::  Try not to get lost!

Offline

#5 2016-02-19 22:08:30

TriforceOfKirby
Member
Registered: 2016-01-26
Posts: 16

Re: [SOLVED] Can I use my Android phone's camera as a webcam?

smirky wrote:

Yes, you can. I used to do that before. For the purpose I used droidcam:

Linux client:
https://aur.archlinux.org/packages/droidcam/

Play Store client:
https://play.google.com/store/apps/deta … s.droidcam

It should work with wireless and usb, although I mostly used it with USB.
I haven't played with it from a long time, but it worked.

AUR package is out of date. Also it seems it can only do 720p; I'd like to do at least 1080p (my phone supports up to 4K).

Last edited by TriforceOfKirby (2016-02-19 22:20:15)

Offline

#6 2016-02-19 22:21:09

smirky
Member
From: Bulgaria
Registered: 2013-02-23
Posts: 277
Website

Re: [SOLVED] Can I use my Android phone's camera as a webcam?

Let me be more specific. Here's a very ugly PKGBUILD I just modified to work with the latest version:

# Maintainer: Daniel Nagy <danielnagy at gmx de>                                                                                   
                                                                                                                                   
pkgname=droidcam                                                                                                                   
pkgver=6.0                                                                                                                         
pkgrel=3                                                                                                                           
_kver="`uname -r | cut -d"." -f1,2`-ARCH"                                                                                          
pkgdesc='A tool for using your android device as a wireless/usb webcam'                                                          
arch=('x86_64')                                                                                                                  
url='http://www.dev47apps.com/'                                                                                                  
license=('custom')                                                                                                               
depends=( 'bluez-libs' 'gtk2')                                                                                                   
makedepends=( 'linux-headers' )                                                                                                  
options=('!strip')                                                                                                               
optdepends=('v4l-utils: Userspace tools and conversion library for Video 4 Linux'                                                
            'xf86-video-v4l: X.org v4l video driver' )                                                                           
install="$pkgname.install"                                                                                                       
                                                                                                                                
source=("$pkgname.desktop" )                                                                                                    
                                                                                                                                
sha1sums=('f85b3f34f98908bd1327df0ea0e650dcbdcb07e9')                                                                           
                                                                                                                                
## as of 2013-10-29 these hash sums worked. But as of 2014-02-03 somethings changed and                                          
## the new hash sums are listed below.                                                                                           
## [[ "${CARCH}" = "i686" ]] && _arch="x86" && sha1sums+=('64fad1b28169f1f5a3cdd03175fac5973fe5d0ef')                            
## [[ "${CARCH}" = "x86_64" ]] && _arch="x64" && sha1sums+=('982ecb2fb2c30adc2fb7f3a2c250ce65b5d40777')                          
                                                                                                                                 
[[ "${CARCH}" = "i686" ]] && _arch="x86" && sha1sums+=('5b00632275a2c09551d1c72703732150b1f685fe')                                
[[ "${CARCH}" = "x86_64" ]] && _arch="x64" && sha1sums+=('09ae94cb7557ec0469759338c7b47e1afd380784')                                
                                                                                                                                       
#source+=("http://www.dev47apps.com/files/50/droidcam-v4l2-${_arch}.tar.gz")                                                           
source+=("https://www.dev47apps.com/files/600/droidcam-64bit.tar.bz2")                                                                  

package() {
  # Install droidcam binary file
  cd ${pkgdir}
  mkdir -p "${pkgdir}"/usr/bin
  install -m755 "$srcdir"/${pkgname}-64bit/$pkgname "$pkgdir"/usr/bin/${pkgname}
  install -m755 "$srcdir"/${pkgname}-64bit/$pkgname-cli "$pkgdir"/usr/bin/${pkgname}-cli

  # Install the desktop icon and ".desktop" files
  install -dm0755 "${pkgdir}/usr/share/"{applications,pixmaps}
#  install -m0644 "${srcdir}/${pkgname}-64bit/icon2.png" "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
  install -m0644 "${srcdir}/${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
  
  mkdir -p "$pkgdir"/usr/lib/modules-load.d/
  printf "videodev\nv4l2loopback\nv4l2loopback_dc" \
         > "$pkgdir"/usr/lib/modules-load.d/droidcam.conf

  mkdir -p "$pkgdir"/etc/modprobe.d/
  printf "options v4l2loopback_dc width=320 height=240" \
         > "$pkgdir"/etc/modprobe.d/droidcam.conf

  # Install doc
  install -dm0755 "${pkgdir}/usr/share/licenses/${pkgname}"
  install -m0644 "${srcdir}/${pkgname}-64bit/README" "${pkgdir}/usr/share/licenses/$pkgname/README"

  # Install modules
  cd $srcdir/$pkgname-64bit/v4l2loopback
  sed -i -e "s,vdev->current_norm,//vdev->current_norm,g" "$srcdir"/$pkgname-64bit/v4l2loopback/*.c
  make
  _extramodules="extramodules-$(uname -r | cut -f-2 -d'.')-$(uname -r|sed -e 's/.*-//g')"
  MODPATH="${pkgdir}/usr/lib/modules/${_extramodules}/"
  install -Dm644 v4l2loopback-dc.ko "$MODPATH/v4l2loopback_dc.ko"
}

Here's what I did to make my 1080p Galaxy S2 work with the desired resolution:

 0 « root » /home/smirky/stuff/ABS/droidcam » modprobe v4l2loopback_dc # pressed tab for bash-completion
height  width                                                                                                                   
 0 « root » /home/smirky/stuff/ABS/droidcam » modprobe v4l2loopback_dc height=1080 width=1920
 0 « root » /home/smirky/stuff/ABS/droidcam » modinfo v4l2loopback_dc 
filename:       /lib/modules/4.4.1-2-ARCH/extramodules/v4l2loopback_dc.ko                                                       
license:        GPL                                                                                                             
author:         Vasily Levin, IOhannes m zmoelnig <zmoelnig@iem.at>, Stefan Diewald, Anton Novikov                              
description:    V4L2 loopback video device                                                                                      
depends:        videodev                                                                                                        
vermagic:       4.4.1-2-ARCH SMP preempt mod_unload modversions                                                                 
parm:           width:frame width (int)                                                                                         
parm:           height:frame height (int) 

I tested the preview with vlc...


Personal spot  ::  https://www.smirky.net/  ::  Try not to get lost!

Offline

#7 2016-02-26 00:20:21

TriforceOfKirby
Member
Registered: 2016-01-26
Posts: 16

Re: [SOLVED] Can I use my Android phone's camera as a webcam?

Thanks that worked.

Offline

Board footer

Powered by FluxBB