We have moved to a new Sailfish OS Forum. Please start new discussions there.
7

Is it possible to use the phone's camera as webcam via USB?

asked 2019-04-03 17:22:08 +0300

laubblaeser gravatar image

Is it possible to use the phone's camera as webcam via USB? Something like this would be my preferred course of actions:

  • connect phone to PC via ssh/USB
  • start webcam script in terminal
  • be able to use the phone's camera feed as a webcam service (e.g. for video chat or simple video recording)

Given the access to the phone's functions that we currently have, would something like this be possible? The only thing I've found on tjc is a question about using external apps (for example the Android app droidcam). I would prefer a simpler solution that directly provides a video feed to my PC. Thanks for your thoughts and answers in advance.

edit retag flag offensive close delete

Comments

Yes, that's the thread I've found. However, as I stated above, it's not exactly what I'd like to do.

laubblaeser ( 2019-04-03 19:50:55 +0300 )edit

2 Answers

Sort by » oldest newest most voted
3

answered 2019-04-03 19:27:08 +0300

DrYak gravatar image

updated 2019-04-03 19:54:58 +0300

from a theoretical point of view, this could be achieved using ffmpeg.

Sailfish OS contains libav (a fork of ffmpeg). You can install the package libav-tools which contains the command avconv (the forks' equivalent of ffmpeg command)

I would start playing with that.

Standard video4linux, v4l2 /dev/video... should work. Mayber android API works too (after all there's an Android kernel underneath Sailfish's libhybris abstraction layer).

Another option would be to make a Gstreamer pipeline using gst-launch


Also as newer versions of sailfish integrate a firewall, remember to open the inbound ports you'd need in your contraption:

iptables -A connman-INPUT -i wlan0 -p tcp -m udp --dport 5353 -j ACCEPT
edit flag offensive delete publish link more

Comments

Thanks for sharing your ideas. I'm no professional coder and I only have very little coding experience in bash and python. So please bear with me if I ask silly questions. Using one of the ways you described, would such a functionality be complicated to set up?

laubblaeser ( 2019-04-03 19:54:11 +0300 )edit
1

I guess what @DrYak is proposing is to do something like ffmpeg ... | nc remoteip remoteport on the phone and then nc -l -p remoteport | mplayer -fps 30 -cache 1024 - on the PC

bomo ( 2019-04-03 20:41:23 +0300 )edit
1

mostly, except that ffmpeg can actually also handle the network part, no need to pipe into netcat.

See the examples in the link I've given for ffmpeg

(Except on the Sailfish device, you'd be calling avconv ... instead of ffmpeg ...)

DrYak ( 2019-04-04 13:33:25 +0300 )edit
0

answered 2019-04-04 03:03:19 +0300

butler gravatar image

You would want something like uvc gadget: git://git.ideasonboard.org/uvc-gadget.git

I've cross compiled it and it doesn't work likely because usb_gadget in kernel is android-specific, not mainline linux type.

If you use linux, it could be possible to create gst pipeline with part on phone, part on PC and v4l2loopback on PC, but currently gstreamer-tools are not installable at least for me.

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
5 followers

Stats

Asked: 2019-04-03 17:22:08 +0300

Seen: 1,128 times

Last updated: Apr 04 '19