Skip to content

Instantly share code, notes, and snippets.

@navarrothiago
Last active May 7, 2024 08:36
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save navarrothiago/8402e3210989d69765bfb3115ccf0732 to your computer and use it in GitHub Desktop.
Save navarrothiago/8402e3210989d69765bfb3115ccf0732 to your computer and use it in GitHub Desktop.
Turn your smartphone or tablet camera into a WebCam to make video conference in Linux

Turn your smartphone or tablet (e.g., Iphone, Ipad, Samsung, Motorola, etc) camera into a WebCam to make video conference (e.g., Google Meeting, Zoom, Discord, etc) in Linux.

Setup - IPCamera App + OBS

Install an app IP camera in your smarthphone

Examples:

Install v4l2loopback

Go to https://github.com/umlaeute/v4l2loopback and see the instructions.
Manjaro Linux users: pamac install v4l2loopback-dkms

Do not forget to install the linux-headers before install the v4l2loopback

Check video devices

ls /dev/video* e.g. output: /dev/video0 /dev/video1

Install OBS Studio

Go to https://obsproject.com/ to get more information.

Install OBS plugin

I used obs-v4l2sink to sink the obs output scenes to the other device created.
Manjaro Linux users: pamac install obs-v4l2sink

Usage

Create two virtual video devices

sudo modprobe v4l2loopback devices=2 video_nr=91,92 exclusive_caps=0,1 OBS:

  • device=2 - 2 capture device (1 to sink to PC and 1 to sink to OBS)
  • video_nr=91,92 - devices ids
  • exclusive_caps=0,1 - only /dev/video92 will be identify by the client (e.g. Google Meeting)

Check the created video devices

ls /dev/video* e.g. output: /dev/video0 /dev/video1 /dev/video91 /dev/video92

Start capture in you smart phone

Open the app in your smartphone and check the ip address. In my case, it shown the IP 192.168.15.5.

Sink video in your first created video device

Open the terminal in your PC and execute:
gst-launch-1.0 souphttpsrc location=http://192.168.15.5:80/live ! jpegdec ! videoconvert ! v4l2sink device=/dev/video91

Obs: Change the ip and the device acording to your configuration.

Open OBS Studio

Open other tab in the terminal and execute obs.

Insert video source

In Sources:

  • click on +
  • select Video Capture Device (V4L2)
  • click on ok
  • On the Device field, select Dummy video device 0
  • click on ok
  • Centralize the added source on the screen

Whooll: you can setup the screen as your wish!!

Sink video in your second created video device

Now, we are going to use the the installed OBS plugin.
In OBS:

  • click on Tools -> v4l2sink -> ok
  • Write on Device Path: /dev/video92 (i.e., the second device created) Now, it will generate a Dummy device 1 (0x0001)

Configure your input video device in your app

e.g., if you are going to use Google Meeting:

Validation setup

  • Iphone 11 iOS 13.5.1 + iPCamera - High-End NetworkCam v1.4 App + Kernel: 5.4.44-1-MANJARO x86_64 + OBS Studio - 25.0.8-1 (linux)

Using Irium Webcam App

References

FEEL FREE TO COMMENT AND CONTRIBUTE

@andersonbosa
Copy link

Pretty cool, thank to sharing!

@mamhadu
Copy link

mamhadu commented May 5, 2024

You save me! Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment