This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Query] Will this driver works for android as well? #330
Comments
try it out ;-) apart from that: i don't see any immediate problems (but again: i have no idea) |
Hi @umlaeute Thanks for your reply. I tried compiling the v4l2loopback driver on Android, able to load and create virtual camera nodes successfully. But when i try to capture a video from this virtual camera device, below issue is observed. Please find the steps, i am following. 1.insmod v4l2loopback.ko exclusive_caps=1 video_nr=23,24 => This is creating the /dev/video23 and /dev/video24 nodes.
Can you please help me in resolving this error. Thanks. |
Hey @Learner379 and you make this? How to? I need to replace a photo. |
Hey @fan3k , Looks like the ffmpeg binary which I was using in android was buggy, as I was not able to stream physical usb camera also. So, I tried adding virtual camera node in to the camerHAL to make it work with the camera applications, but was not succeeded here also. Please let me know if you have any inputs. And also what is the exact issue which you are facing? |
@umlaeute , Did you try to make this repo work on Android? |
@Learner379 Can you please provide the steps to took to compile the kernel module for android? Trying to make this work on Pixel 5. |
Build v4l2loopback for android need the kernel source (or headers & symbols) use to build your android image.
I did all upper steps success BUT the Android9 (on my rockchip board) not recognize v4l2loopback virtual camera as a system camera. Another virtual camera solution Still working in progress... |
According to the android souce (hardware/interfaces/camera/device/3.4/default/ExternalCameraDevice.cpp), the V4L2 video device must be act as a VIDEO_CAPTURE device and support V4L2_PIX_FMT_MJPEG or V4L2_PIX_FMT_YUYV once it first connected (and never check again). So, the current v4l2loopback can not support android (to use as a camera). To fix this, I patch the source with:
Now, the camera APP detect the virtual device (without crash), but when I write YUYV422 stream, camera read nothing diff --git a/v4l2loopback.c b/v4l2loopback.c
index 9da2508..e0ec3a6 100644
--- a/v4l2loopback.c
+++ b/v4l2loopback.c
@@ -207,7 +207,7 @@ static const struct v4l2_ctrl_config v4l2loopback_ctrl_keepformat = {
.min = 0,
.max = 1,
.step = 1,
- .def = 0,
+ .def = 1,
// clang-format on
};
static const struct v4l2_ctrl_config v4l2loopback_ctrl_sustainframerate = {
@@ -2030,6 +2030,21 @@ static void timeout_timer_clb(unsigned long nr)
spin_unlock(&dev->lock);
}
+static int set_default_format(struct v4l2_loopback_device *dev)
+{
+ //const struct v4l2l_format *format = &formats[3]; // V4L2_PIX_FMT_RGB24, 24 bpp RGB, be
+ //const struct v4l2l_format *format = &formats[1]; // V4L2_PIX_FMT_RGB32, 32 bpp RGB, be
+ const struct v4l2l_format *format = &formats[11]; // V4L2_PIX_FMT_YUYV,4:2:2, packed, YUYV
+ struct v4l2_pix_format *pix_fmt = &dev->pix_format;
+
+ pix_fmt->width = 800;
+ pix_fmt->height = 600;
+ pix_format_set_size(pix_fmt, format, 800, 600);
+ pix_fmt->pixelformat = format->fourcc;
+ pix_fmt->colorspace = V4L2_COLORSPACE_SRGB;
+ return 0;
+}
+
/* init loopback main structure */
#define DEFAULT_FROM_CONF(confmember, default_condition, default_value) \
((conf) ? \
@@ -2207,7 +2222,9 @@ v4l2_loopback_add(struct v4l2_loopback_config *conf)
V4L2_COLORSPACE_SRGB; /* do we need to set this ? */
dev->pix_format.field = V4L2_FIELD_NONE;
+ set_default_format(dev);
dev->buffer_size = PAGE_ALIGN(dev->pix_format.sizeimage);
+ dev->pix_format.sizeimage = dev->buffer_size;
dprintk("buffer_size = %ld (=%u)\n", dev->buffer_size,
dev->pix_format.sizeimage);
err = allocate_buffers(dev);
@@ -2224,6 +2241,7 @@ v4l2_loopback_add(struct v4l2_loopback_config *conf)
goto out_free_device;
}
v4l2loopback_create_sysfs(dev->vdev);
+ dev->ready_for_capture = 1;
return dev;
|
@rediceli Thanks a lot for explaining everything clearly, I'll try the above and get back |
Have you attempted to create video nodes, move the original video nodes for the original cameras, and then link the v4l2loopback video nodes to the positions where the original nodes were? |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hi,
I am new to this, Can anybody please share me the exact steps to create the virtual camera device/loop back device in android.
Thank you
The text was updated successfully, but these errors were encountered: