[英]How can I send a virtual camera to Genymotion or Android Studio Emulator in Ubuntu?
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我使用 v4l2loopback 和 ffmpeg 创建了一个虚拟相机。我用于 ffmpeg 的命令是: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. vin.png 是我想要 stream 到网络摄像头的图像,/dev/video2 是我用 v4l2loopback 创建的虚拟网络摄像头。 The virtual webcam works and I can see it eg with onlinemicetest.com/webcam-test .
虚拟网络摄像头有效,我可以通过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.
我在 Ubuntu 20.40 上使用 Genymotion 模拟器和最新的 Android API(我试过 7.0、8.1 和 10.0)。 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.
Genymotion detects the virtual camera but only displays a dummy image: Wrong dummy Image from Genymotion我也试过(并且更愿意使用)android 工作室模拟器。 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.
但是我只能在设备摄像头的配置中将 select Webcam0 指向真正的集成摄像头,而不是我的虚拟网络摄像头。
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.我不需要使用 ffmpeg,但我确实需要使用一个工具,让我从命令行控制将哪个图像发送到 stream。
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. 2020 年 11 月 17 日更新:Genymotion 支持人员回答我,他们计划在未来支持虚拟相机。 They might be ready to add this in mid 2021.
他们可能准备在 2021 年年中添加此功能。
1, Edit the picture with 640 480 format, and generate the streaming " ffmpeg -re -l oop 1 -i 640 480.png -vf format=yuv420p -f v4l2 /dev/video0". 1、编辑640480格式的图片,生成推流“ffmpeg -re -l oop 1 -i 640 480.png -vf format=yuv420p -f v4l2 /dev/video0”。
2, Now the genymotion camera setting display OK. 2、此时genymotion相机设置显示OK。
3, But it still can't take picture from the virtual camera, :(. 3,但是还是不能从虚拟相机拍照,:(。
genymotion virtual camera test with 640*480 Picture 640*480 图片的 genymotion 虚拟相机测试
You can't: Genymotion does not support virtual cameras.你不能:Genymotion 不支持虚拟相机。 See https://support.genymotion.com/hc/en-us/articles/360002734498-My-webcam-does-not-work-with-Genymotion-Desktop
请参阅https://support.genymotion.com/hc/en-us/articles/360002734498-My-webcam-does-not-work-with-Genymotion-Desktop
Solution using OBS and Android Emulator:使用OBS和Android Emulator的解决方案:
I created a virtual camera using v4l2loopback and ffmpeg.我使用 v4l2loopback 和 ffmpeg 创建了一个虚拟相机。 The command I use for ffmpeg is: ffmpeg -re -l oop 1 -i vin.png -vf format=yuv420p -f v4l2 /dev/video2
我用于 ffmpeg 的命令是: ffmpeg -re -l oop 1 -i vin.png -vf format=yuv420p -f v4l2 /dev
vin.png is the image I want to stream to the webcam and /dev/video2 is the virtual webcam I created with v4l2loopback. vin.png 是我想要 stream 到网络摄像头的图像,/dev/video2 是我使用 v4l2loopback 创建的虚拟网络摄像头。 The virtual webcam works and I can see it eg with onlinemicetest.com/webcam-test .
虚拟网络摄像头有效,我可以通过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.
我在 Z3D945423F8E9496C429A5D8C65B4604F 上使用带有最新 Android API(我试过 7.0、8.1 和 10.0)的 Genymotion 模拟器。 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.
Genymotion 检测到虚拟相机,但只显示一个虚拟图像:来自 Genymotion 的错误虚拟图像我也尝试过(并且更愿意使用)android 工作室模拟器。 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.
但是我只能在设备摄像头的配置中配置 select Webcam0 并且指向真正的集成摄像头而不是我的虚拟摄像头。
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.我不需要使用 ffmpeg,但我确实需要使用一个工具来控制从命令行到 stream 的图像。
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. 2020 年 11 月 17 日更新:Genymotion 支持回答我,他们计划在未来支持虚拟相机。 They might be ready to add this in mid 2021.
他们可能准备在 2021 年年中添加此功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.