# How to make the computer think Processing is a camera (video capture device)?

**URL:** <https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696>\
**Category:** Project Guidance\
**Created:** [February 10, 2021, 1:17am UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696 "2021-02-10T01:17:35Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 10, 2021, 1:17am UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/1 "2021-02-10T01:17:35Z")

</div>

I have heard of spout & syphon but I have no idea on how to get started.

In these pandemic, videoconferencing, times, it could be fun to feed a sketch instead of me.

I suppose one could do it with OBS too? I’m on Linux.

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [February 15, 2021, 10:59am UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/2 "2021-02-15T10:59:57Z")

</div>

Potentially PipeWire will offer something similar to Spout and Syphon - [https://pipewire.org/](https://pipewire.org/)

You can potentially use GStreamer with v4l2loopback to capture any window, including a Processing sketch, and route it back as a camera. Or stream it directly.

However, if you just want to share it in video conferencing, you shouldn’t need any of this - just share (present) the window directly?!

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 15, 2021, 2:48pm UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/3 "2021-02-15T14:48:12Z")

</div>

Thanks! I’ll investigate PipeWire and v4l2loopback!

> [@neilcsmith](#):
>
> However, if you just want to share it in video conferencing, you shouldn’t need any of this - just share (present) the window directly?!

No really, because I’m not presenting. It would replace my ‘normal’ camera feed, possibly with a ‘filtered’ version of me (like my circles-grid avatar here, for instance)

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [February 15, 2021, 5:04pm UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/4 "2021-02-15T17:04:44Z")

</div>

Yes, v4l2loopback is interesting - have used that a few times. It’s a kernel module, so once installed you usually need to use -

```bash
sudo modprobe v4l2loopback

```

By default that will create a new `/dev/video*` device. On my desktop without a camera that will be `/dev/video0`, but on a laptop usually `/dev/video1`. You can also add parameters to the module install to create more loopback devices - eg. this project used 2 cameras and 4 loopback devices at different resolutions for motion tracking and display - [https://youtu.be/9D3cJDRF6Do](https://youtu.be/9D3cJDRF6Do)

Once you have the loopback device installed, try running a sketch and then in the terminal run (where device is from above) -

```bash
gst-launch-1.0 ximagesrc xname="<SketchWindowTitle>" use-damage=false show-pointer=false ! videoconvert ! v4l2sink device=/dev/video0

```

This should make the sketch available as a camera at the same device name. You can test in Processing itself, or from a different terminal

```bash
gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! autovideosink

```

---

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [February 15, 2021, 6:15pm UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/5 "2021-02-15T18:15:01Z")

</div>

Hi! I tried this last year:

> **[hamoid/Fun-Programming](https://github.com/hamoid/Fun-Programming/tree/master/processing/ideas/2020/04)**
>
> master/processing/ideas/2020/04

There’s 3 examples. I haven’t looked at the code since then but I guess you can figure it out? 🙂

I used akvcam I think on ArchLinux.

I see I posted a video about it on twitter, but they reduced it to 5 bits per second:

[https://twitter.com/search?q=%40hamoid%20akvcam&src=typed\_query](https://twitter.com/search?q=%40hamoid%20akvcam&src=typed_query)

Maybe I can find the videos again… yes:  
https://player.vimeo.com/video/512631577  
https://player.vimeo.com/video/512631711

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 15, 2021, 8:34pm UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/6 "2021-02-15T20:34:11Z")

</div>

> [@neilcsmith](#):
>
> `sudo modprobe v4l2loopback`

Thanks! I tried to install but that is not working, yet, I’m on Manjaro so I’ll see if changing kernels helps…

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 15, 2021, 8:35pm UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/7 "2021-02-15T20:35:42Z")

</div>

> [@hamoid](#):
>
> I used akvcam I think on ArchLinux.

Wow, that looks wonderful, I’l have a look. I’m not very skilled at Linux, but Manjaro is close to ArchLinux I think, so I might get lucky.

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [February 16, 2021, 10:02am UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/8 "2021-02-16T10:02:14Z")

</div>

> [@hamoid](#):
>
> I used akvcam I think on ArchLinux.

Interesting! Not seen that before. Looks like they work the same way? In which case the GStreamer pipelines above should also work the same, and vice versa - your sketches work with v4l2loopback. Any idea why choose one over the other? It’s been a while since I’ve needed to do this, so I’m curious what the pros and cons are.

The sketch writing raw pixel data to the device is interesting. That work OK? Never thought of trying that.

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 16, 2021, 12:44pm UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/9 "2021-02-16T12:44:58Z")

</div>

hehehe, I have to make time to try again, but couldn’t make either work yet…

---

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [February 16, 2021, 6:57pm UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/10 "2021-02-16T18:57:35Z")

</div>

> [@neilcsmith](#):
>
> The sketch writing raw pixel data to the device is interesting. That work OK? Never thought of trying that.

It did work when I tried 🙂

Not sure how to choose… I guess try and if the first doesn’t work, try the second 🙂

@villares There’s no official package. I compiled it somehow. But the aur package seems to be broken at the time: [AUR (en) - akvcam-dkms](https://aur.archlinux.org/packages/akvcam-dkms/)

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 16, 2021, 10:35pm UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/11 "2021-02-16T22:35:37Z")

</div>

Yeah I tried the AUR and then saw in your video that you compiled, I have to try it soon 🙂 Thanks again!

---

<div class="post-metadata">

**Author:** ![janebeta7](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/janebeta7/32/101_2.png) [@janebeta7](https://discourse.processing.org/u/janebeta7)\
**Post date:** [February 24, 2023, 1:49pm UTC](https://discourse.processing.org/t/how-to-make-the-computer-think-processing-is-a-camera-video-capture-device/27696/12 "2023-02-24T13:49:01Z")

</div>

Hello! I am trying this but i have an error

```auto
gst-launch-1.0 ximagesrc xname="name_display_processing_window" ! videoconvert ! video/x-raw,format=RGB,framerate=10/1 ! identity drop-allocation=1 ! v4l2sink device=/dev/video6 

```

```auto
Estableciendo el conducto a PAUSA …
El conducto está vivo y no necesita PREPARARSE …
El conducto está PREPARADO …
Estableciendo el conducto a REPRODUCIENDO …
New clock: GstSystemClock
X Error of failed request: BadMatch (invalid parameter attributes)
  Major opcode of failed request: 130 (MIT-SHM)
  Minor opcode of failed request: 4 (X_ShmGetImage)
  Serial number of failed request: 455
  Current serial number in output stream: 455

```
