2

I created a virtual camera using v4l2loopback and ffmpeg. The command I use for ffmpeg is: ffmpeg -re -l oop 1 -i vin.png -vf format=yuv420p -f v4l2 /dev/video2

vin.png is the image I want to stream to the webcam and /dev/video2 is the virtual webcam I created with v4l2loopback. The virtual webcam works and I can see it e.g. with onlinemicetest.com/webcam-test. I'm using the Genymotion emulator with the newest Android API (I tried 7.0, 8.1 and 10.0) on Ubuntu 20.40. Genymotion detects the virtual camera but only displays a dummy image: Wrong dummy Image from Genymotion I also tried (and would prefer to use) the android studio emulator. But I can only select Webcam0 in the configuration of the device camera and that points to the real integrated camera and not to my virtual webcam.

I don't need to use ffmpeg, but I do need to use a tool that lets me control which image to stream from the command line.

Is there a way to solve this? Many thanks in advance!

Update 17.11.2020: The Genymotion support answered me, that they plan to support virtual cameras in the future. They might be ready to add this in mid 2021.

ykasur
  • 183
  • 1
  • 11

3 Answers3

1

1, Edit the picture with 640480 format, and generate the streaming " ffmpeg -re -l oop 1 -i 640480.png -vf format=yuv420p -f v4l2 /dev/video0".

2, Now the genymotion camera setting display OK.

3, But it still can't take picture from the virtual camera, :(.

genymotion virtual camera test with 640*480 Picture

error in take picture

0

You can't: Genymotion does not support virtual cameras. See https://support.genymotion.com/hc/en-us/articles/360002734498-My-webcam-does-not-work-with-Genymotion-Desktop

Julien
  • 466
  • 2
  • 3
0

Solution using OBS and Android Emulator:

  1. follow this tutorial: https://blog.jbrains.ca/permalink/using-obs-studio-as-a-virtual-cam-on-linux
  2. use these commands to change your obs scenes: https://gist.github.com/nooitaf/9aabf72d00e16a61ea301c69ff38d804
  3. check which /dev/video you are using: v4l2-ctl --list-devices
  4. check which webcam is linked to that video in your avd: ./emulator -avd Pixel2 -webcam-list
  5. use that webcam to start emulator from command line: ./emulator -avd Pixel2 -camera-back webcam2
ykasur
  • 183
  • 1
  • 11