How can I send a virtual camera to Genymotion or Android Studio Emulator in Ubuntu?

瘦欲@ 提交于 2021-01-29 08:07:16

问题


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.


回答1:


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




回答2:


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



回答3:


I have finish the 1,2,3 steps but I don't understand 5,6 steps; What's the meaning ? Does it works in genymotion ? Thank you for all of these info.




回答4:


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



来源:https://stackoverflow.com/questions/65007357/how-can-i-send-a-virtual-camera-to-genymotion-or-android-studio-emulator-in-ubun

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!