Writings Photos Code Contact Resume Me
Introducing vcamera, a virtual V4L2 camera.
Submitted by msameer on Mon, 20/06/2011 - 7:03pm

This is a kernel module I cooked in a couple of days. The idea is to expose a v4l device that gets its data from user space.

I had 2 use cases in mind:
1) Educational purpose for myself (I'm really a kernel noob).
2) Streaming movies over skype, google talk, ... etc.

The idea could be good or completely rubbish but hey ? Learning can only be done with stupid ideas!

The code is highly unstable. It shouldn't oops the kernel but I'm not responsible. I've been developing and testing it inside qemu.

Clone it from the git repository via:

git clone git@gitorious.org:vcamera/vcamera.git

Here are a few missing bits off the top of my head:

* I'm not following the kernel coding style yet ;-)
* I'm sure my locking, unlocking and concurrency handling is flawed.
* The code is a bit fragile.
* It'd be nice to implement mmap support for the character device. This should eliminate data copies.
* Perhaps expose the character device all the time and generate "fake" frames when streaming starts ? Problem now is one has to be very fast in feeding data to the module otherwise select() on the v4l device will timeout.
* Many more...

If someone finds this idea useful, please drop me a line.
Comments, use cases, ideas and tips are really welcomed!

If I see a lot of interest, I might try to push it to the kernel tree one day ;-)

Update: Seems vloopback already exists and renders my code useless. I might still do something with it as my idea seems a bit simpler but whatever.

Update 2: There's also v4l2loopback and its fork.

Syndicate content  digg  bookmark

Submitted by Ahmed Kamal (not verified) on Mon, 20/06/2011 - 8:38pm.

Sounds like WebCamStudio http://www.ws4gl.org/
Still sounds like an exciting adventure .. best of luck man

Submitted by Eric Cooper (not verified) on Mon, 20/06/2011 - 10:15pm.

I haven't looked at your code yet, but don't assume it's useless. Unless it's been updated recently, vloopback is v4l-only, not v4l2. There's also a v4l2loopback project out there, but it supports only a very limited number of image formats (by design), so you typically need to set up your own transcoding pipeline to use it.

Submitted by msameer on Mon, 20/06/2011 - 10:38pm.

I won't be doing any conversion in kernel space so vcamera will output exactly what it's being fed from userspace.

Not much formats are supported now but the set can be expanded to cover all the V4L2 formats available.

I might ditch the character device completely and create a v4l2 device for feeding data but not sure yet.

Post new comment
(If you're a human, don't change the following field)
Your first name.
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <dd> <dl> <dt> <i> <s> <li> <ol> <u> <ul> <br> <br /> <blockquote>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.

More information about formatting options