# Streaming OPENRNDR live coding on Linux

**URL:** <https://openrndr.discourse.group/t/streaming-openrndr-live-coding-on-linux/101>\
**Category:** Libraries and extensions\
**Created:** [May 4, 2020, 12:44pm UTC](https://openrndr.discourse.group/t/streaming-openrndr-live-coding-on-linux/101 "2020-05-04T12:44:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kazik](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/kazik/32/7_2.png) [@kazik](https://openrndr.discourse.group/u/kazik)\
**Post date:** [May 4, 2020, 12:44pm UTC](https://openrndr.discourse.group/t/streaming-openrndr-live-coding-on-linux/101/1 "2020-05-04T12:44:05Z")

</div>

I just customized `openrndr-template` to use `v4l2loopback` in order to stream OPENRNDR output. Might be useful for creating on the fly camera filters in the time of social distancing:

[https://github.com/morisil/openrndr-camera-filter](https://github.com/morisil/openrndr-camera-filter)

---

<div class="post-metadata">

**Author:** ![edwin](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@edwin](https://openrndr.discourse.group/u/edwin)\
**Post date:** [May 5, 2020, 9:07am UTC](https://openrndr.discourse.group/t/streaming-openrndr-live-coding-on-linux/101/2 "2020-05-05T09:07:15Z")

</div>

Ah interesting, I just have v4l2loopback setup here, will try to find some time to get this going.

---

<div class="post-metadata">

**Author:** ![kazik](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/kazik/32/7_2.png) [@kazik](https://openrndr.discourse.group/u/kazik)\
**Post date:** [May 5, 2020, 10:58am UTC](https://openrndr.discourse.group/t/streaming-openrndr-live-coding-on-linux/101/3 "2020-05-05T10:58:08Z")

</div>

I changed default pixel format to `rgb24` from `yuv420p`, and ffmpeg CPU usage dropped from 94% to 50% for FullHD resolution (one core). After this change I was still able to pick the camera in Jitsi opened in Chrome. I see that availability of the camera to certain application depends a lot on the resolution. If it’s too big Skype will not pick it for example. I guess also the output frame rate specification should be fixed in my code. Still not sure how. I guess just the extra `-r` parameter for the output video.I see that in the `VideoWriter` it’s only allowed to specify integer value frame rate for the input video stream and this one right now gets inherited for the output and defaults to 25 fps. But I was thinking that maybe this value should be actually floating point in general if someone’s screen has weird refresh rate like 59,93Hz? But it seems that it makes any timing quite difficult. Still my screen is currently 60Hz, so I guess input video frame rate should be set to 60 fps, and output to something more reasonable for streaming, maybe 25, maybe 20.

---

<div class="post-metadata">

**Author:** ![edwin](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@edwin](https://openrndr.discourse.group/u/edwin)\
**Post date:** [May 5, 2020, 11:09am UTC](https://openrndr.discourse.group/t/streaming-openrndr-live-coding-on-linux/101/4 "2020-05-05T11:09:26Z")

</div>

I believe @abe worked on something similar using `akvcam`, if I am not mistaken he was able to write to `/dev/videoN` directly and bypassing FFMPEG altogether.

---

<div class="post-metadata">

**Author:** ![kazik](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/kazik/32/7_2.png) [@kazik](https://openrndr.discourse.group/u/kazik)\
**Post date:** [May 5, 2020, 11:37am UTC](https://openrndr.discourse.group/t/streaming-openrndr-live-coding-on-linux/101/5 "2020-05-05T11:37:25Z")

</div>

Yes, I talked with him about it, but I was not able to get `akvcam` to work on my computer. Now it seems that it’s because I enabled secure boot, which means I have to sign newly compiled kernel modules 🙂

---

<div class="post-metadata">

**Author:** ![kazik](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/kazik/32/7_2.png) [@kazik](https://openrndr.discourse.group/u/kazik)\
**Post date:** [May 5, 2020, 1:13pm UTC](https://openrndr.discourse.group/t/streaming-openrndr-live-coding-on-linux/101/6 "2020-05-05T13:13:25Z")

</div>

I was finally able to use `akvcam` and I adapted @abe 's code as an `Extension` and pushed it. I used NIO channels directly instead of allocating extra byte array. Still I am quite disappointed with the performance and stability. Going FullHD is crashing my computer immediately. Trying with just 640x480 resolution sooner or later blocks something, causing a crash after a while and I have to do the hard reset, which actually I realized is almost never happening to me on linux, maybe once in 6 months. ☹ I had to do this as well:

```auto
$ echo "1" >/sys/devices/virtual/video4linux/video7/controls/vflip

```

Even with such a limited resolution `akvcam` seems to be heavily dropping frames while `v4l2loopback` goes quite well with FullHD 60 fps and 50% of CPU on 1 core. Maybe it works better with other drivers. I’m on intel here.
