Nimbin[12]?Linux & System / webcam-loopback-manipulation-screensharing-and-stuff / commits / 74e35c1

webcam-loopback-manipulation-screensharing-and-stuff git · main

vcam: v4l2 loopback with overlays, filters, OpenCV and RVM matting

webcam v4l2 opencv onnx c · first commit 2026-06-29 · last commit 2026-11-12 (11 days ago) · synced 1 hour ago · upstream: github.com/nimbin2/Webcam-Filter---ScreenSharing---and-Stuff

C 51.3% C++ 40.7% Markdown 6.9% Makefile 1%
git clone https://git.christianimmanuel.de/linux-system/webcam-loopback-manipulation-screensharing-and-stuff.gitwget https://git.christianimmanuel.de/linux-system/webcam-loopback-manipulation-screensharing-and-stuff/archive/webcam-loopback-manipulation-screensharing-and-stuff.tar.gz

Add color filter Add License Update Readme and so on

Christian Immanuel · 2026-07-05 17:24 · 74e35c12340d4f394ceffa22fe76bb479b66a8bb

 src/capture.c     | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/filter.c      | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 src/frame.c       |  8 +++++
 src/ipc.c         | 48 +++++++++++++++++++++++++++--
 src/main.c        | 72 +++++++++++++++++++++++++++++++++++++-------
 src/output.c      |  8 +++++
 src/overlay.c     |  8 +++++
 src/record.c      |  8 +++++
 src/registry.c    |  8 +++++
 src/test_screen.c |  8 +++++
 10 files changed, 326 insertions(+), 21 deletions(-)

diff --git a/src/capture.c b/src/capture.c
index 4a8f706..967b1a3 100644
--- a/src/capture.c
+++ b/src/capture.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * vcam — Linux virtual webcam pipeline
+ * Copyright (C) 2026 the vcam authors
+ *
+ * This program is free software under the terms of the GNU General
+ * Public License version 2. See the LICENSE file for the full text.
+ */
+
 #include "vcam.h"
 
 #include <stdio.h>
@@ -153,6 +161,87 @@ static bool pick_format(int fd, int req_w, int req_h, int target_fps,
     return true;
 }
 
+/* ── list supported formats ───────────────────────
+ * Opens the device, enumerates every (pixel format, resolution, fps)
+ * combination the driver reports, and prints a human-readable table
+ * to stdout. Used by `vcam --list-formats`. Returns true on success.
+ *
+ * Only the pixel formats vcam can actually consume are shown, since
+ * listing formats we can't decode would be misleading. For each
+ * discrete frame size the maximum discrete frame rate is reported. */
+bool capture_list_formats(const char *device)
+{
+    int fd = open(device, O_RDWR | O_NONBLOCK, 0);
+    if (fd < 0) {
+        fprintf(stderr, "vcam: cannot open %s: %s\n", device, strerror(errno));
+        return false;
+    }
+
+    struct v4l2_capability caps = {0};
+    if (xioctl(fd, VIDIOC_QUERYCAP, &caps) == 0)
+        printf("Capture device: %s (%s)\n", device, caps.card);
+    else
+        printf("Capture device: %s\n", device);
+
+    /* Formats vcam can consume, in the same preference order as pick_format */
+    const __u32 usable[] = {
+        V4L2_PIX_FMT_MJPEG, V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_NV12,
+        V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_RGB24,
+    };
+    const size_t n_usable = sizeof usable / sizeof usable[0];
+
+    printf("\n  %-8s %-12s %s\n", "format", "resolution", "max fps");
+    printf("  %-8s %-12s %s\n", "------", "----------", "-------");
+
+    int shown = 0;
+    struct v4l2_fmtdesc fmt = {0};
+    fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+    for (fmt.index = 0; xioctl(fd, VIDIOC_ENUM_FMT, &fmt) == 0; fmt.index++) {
+        bool ok = false;
+        for (size_t i = 0; i < n_usable; i++)
+            if (usable[i] == fmt.pixelformat) { ok = true; break; }
+        if (!ok) continue;   /* skip formats we can't decode */
+
+        struct v4l2_frmsizeenum fs = {0};
+        fs.pixel_format = fmt.pixelformat;
+        for (fs.index = 0;
+             xioctl(fd, VIDIOC_ENUM_FRAMESIZES, &fs) == 0;
+             fs.index++) {
+            if (fs.type != V4L2_FRMSIZE_TYPE_DISCRETE) continue;
+            int w = fs.discrete.width, h = fs.discrete.height;
+
+            /* find the highest discrete fps for this size */
+            int max_fps = 0;
+            struct v4l2_frmivalenum fi = {0};
+            fi.pixel_format = fmt.pixelformat;
+            fi.width = w; fi.height = h;
+            for (fi.index = 0;
+                 xioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &fi) == 0;
+                 fi.index++) {
+                if (fi.type != V4L2_FRMIVAL_TYPE_DISCRETE) continue;
+                int fps = fi.discrete.denominator /
+                          (fi.discrete.numerator ? fi.discrete.numerator : 1);
+                if (fps > max_fps) max_fps = fps;
+            }
+
+            char res[16];
+            snprintf(res, sizeof res, "%dx%d", w, h);
+            if (max_fps > 0)
+                printf("  %-8s %-12s %d\n", fourcc(fmt.pixelformat), res, max_fps);
+            else
+                printf("  %-8s %-12s %s\n", fourcc(fmt.pixelformat), res, "?");
+            shown++;
+        }
+    }
+
+    if (shown == 0)
+        printf("  (no usable discrete formats reported)\n");
+
+    printf("\nPick one with:  vcam --res WxH [-f FPS]\n");
+    close(fd);
+    return true;
+}
+
 /* ── open ─────────────────────────────────────── */
 V4L2Capture *capture_open(const char *device,
                            int *out_width, int *out_height, int *out_fps)
diff --git a/src/filter.c b/src/filter.c
index 7ad1787..3c187d5 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * vcam — Linux virtual webcam pipeline
+ * Copyright (C) 2026 the vcam authors
+ *
+ * This program is free software under the terms of the GNU General
+ * Public License version 2. See the LICENSE file for the full text.
+ */
+
 /*
  * filter.c – per-pixel effects applied to a BGR24 frame in place.
  *
@@ -3303,6 +3311,7 @@ static void fx_life(Frame *f, float density, float colormode, float speed)
 
 enum {
     EN_CONST, EN_X, EN_Y, EN_W, EN_H, EN_T, EN_R, EN_A,
+    EN_CR, EN_CG, EN_CB,   /* input pixel color channels 0..255 */
     EN_ADD, EN_SUB, EN_MUL, EN_DIV, EN_MOD, EN_NEG,
     EN_SIN, EN_COS, EN_ABS, EN_SQRT, EN_FLOOR,
     EN_GT, EN_LT, EN_GE, EN_LE, EN_EQ, EN_NE,
@@ -3395,6 +3404,13 @@ static int expr_parse_factor(ExprParser *p)
         p->s++;
         return expr_node(p, op, 0, c, -1);
     }
+    /* two-char color-input variables: cr cg cb (must test before the
+     * single-char switch, since 'c' alone is not a variable) */
+    if (s[0] == 'c') {
+        if (s[1] == 'r') { p->s = s + 2; return expr_node(p, EN_CR, 0, -1, -1); }
+        if (s[1] == 'g') { p->s = s + 2; return expr_node(p, EN_CG, 0, -1, -1); }
+        if (s[1] == 'b') { p->s = s + 2; return expr_node(p, EN_CB, 0, -1, -1); }
+    }
     switch (*s) {
     case 'x': p->s = s + 1; return expr_node(p, EN_X, 0, -1, -1);
     case 'y': p->s = s + 1; return expr_node(p, EN_Y, 0, -1, -1);
@@ -3465,7 +3481,7 @@ static int expr_parse_ternary(ExprParser *p)
     return expr_node3(p, EN_TERN, cond, then_e, else_e);
 }
 
-typedef struct { float x, y, w, h, t, r, a; } ExprVars;
+typedef struct { float x, y, w, h, t, r, a, cr, cg, cb; } ExprVars;
 
 static float expr_eval(const ExprProg *pr, int node, const ExprVars *v)
 {
@@ -3479,6 +3495,9 @@ static float expr_eval(const ExprProg *pr, int node, const ExprVars *v)
     case EN_T: return v->t;
     case EN_R: return v->r;
     case EN_A: return v->a;
+    case EN_CR: return v->cr;
+    case EN_CG: return v->cg;
+    case EN_CB: return v->cb;
     case EN_ADD: return expr_eval(pr, n->a, v) + expr_eval(pr, n->b, v);
     case EN_SUB: return expr_eval(pr, n->a, v) - expr_eval(pr, n->b, v);
     case EN_MUL: return expr_eval(pr, n->a, v) * expr_eval(pr, n->b, v);
@@ -3527,9 +3546,14 @@ static bool expr_compile(ExprProg *prog, const char *src,
     return true;
 }
 
-/* Global mathwarp program (one instance; protected by its own lock
- * because IPC compiles while the render thread evaluates). */
+/* Global mathwarp programs (one instance each; protected by one lock
+ * because IPC compiles while the render thread evaluates).
+ *   dx, dy       — pixel displacement (warp)
+ *   cr, cg, cb   — output color per channel (recolor); when unset the
+ *                  warped source color passes through unchanged. */
 static ExprProg g_mw_dx, g_mw_dy;
+static ExprProg g_mw_cr, g_mw_cg, g_mw_cb;
+static bool     g_mw_color_on = false;
 static pthread_mutex_t g_mw_lock = PTHREAD_MUTEX_INITIALIZER;
 
 bool mathwarp_set_expr(const char *dx_expr, const char *dy_expr,
@@ -3545,11 +3569,38 @@ bool mathwarp_set_expr(const char *dx_expr, const char *dy_expr,
     return true;
 }
 
+bool mathwarp_set_color(const char *r_expr, const char *g_expr,
+                        const char *b_expr, char *err, size_t errlen)
+{
+    ExprProg cr, cg, cb;
+    if (!expr_compile(&cr, r_expr, err, errlen)) return false;
+    if (!expr_compile(&cg, g_expr, err, errlen)) return false;
+    if (!expr_compile(&cb, b_expr, err, errlen)) return false;
+    pthread_mutex_lock(&g_mw_lock);
+    g_mw_cr = cr;
+    g_mw_cg = cg;
+    g_mw_cb = cb;
+    g_mw_color_on = true;
+    pthread_mutex_unlock(&g_mw_lock);
+    return true;
+}
+
+void mathwarp_clear_color(void)
+{
+    pthread_mutex_lock(&g_mw_lock);
+    g_mw_color_on = false;
+    pthread_mutex_unlock(&g_mw_lock);
+}
+
 /* ─── fx_mathwarp ──
- * Displaces each pixel by (dx, dy) computed from the user's
- * expressions. Evaluated every 4th pixel, bilinearly upsampled.
+ * Displaces each pixel by (dx, dy) from the user's warp expressions
+ * (evaluated on a 1/4 grid + bilinearly upsampled), then optionally
+ * recolors each pixel with the color expressions (evaluated per-pixel
+ * so they can read that pixel's own cr/cg/cb).
  *   amp (param): global multiplier on the displacement.
- * Set expressions live:  vcam-ctl filter expr <dx> <dy>
+ * Set expressions live:
+ *   vcam-ctl filter expr  <dx> <dy>        (warp)
+ *   vcam-ctl filter color <r> <g> <b>      (recolor; 0..255 each)
  */
 static void fx_mathwarp(Frame *f, float amp)
 {
@@ -3562,8 +3613,12 @@ static void fx_mathwarp(Frame *f, float amp)
     }
     ExprProg dx_prog = g_mw_dx;
     ExprProg dy_prog = g_mw_dy;
+    bool color_on = g_mw_color_on;
+    ExprProg cr_prog = g_mw_cr, cg_prog = g_mw_cg, cb_prog = g_mw_cb;
     pthread_mutex_unlock(&g_mw_lock);
     if (!dx_prog.valid || !dy_prog.valid) return;
+    if (color_on && (!cr_prog.valid || !cg_prog.valid || !cb_prog.valid))
+        color_on = false;
 
     int w = f->width, h = f->height;
     int GW = w / 4 + 2, GH = h / 4 + 2;
@@ -3577,6 +3632,7 @@ static void fx_mathwarp(Frame *f, float amp)
     v.w = (float)w;
     v.h = (float)h;
     v.t = (float)anim_tick() / 30.0f;
+    v.cr = v.cg = v.cb = 0.0f;   /* unused during warp-grid eval */
     float cx = w / 2.0f, cy = h / 2.0f;
 
     for (int gy = 0; gy < GH; gy++) {
@@ -3596,6 +3652,7 @@ static void fx_mathwarp(Frame *f, float amp)
         uint8_t *dst = f->data + y * f->stride;
         int gy = y / 4;
         float fy = (float)(y & 3) / 4.0f;
+        v.y = (float)y;
         for (int x = 0; x < w; x++) {
             int gx = x / 4;
             float fx = (float)(x & 3) / 4.0f;
@@ -3615,7 +3672,26 @@ static void fx_mathwarp(Frame *f, float amp)
             if (sy >= h) sy = h - 1;
             const uint8_t *sp = src + sy * w * 3 + sx * 3;
             int o = x * 3;
-            dst[o] = sp[0]; dst[o+1] = sp[1]; dst[o+2] = sp[2];
+
+            if (!color_on) {
+                dst[o] = sp[0]; dst[o+1] = sp[1]; dst[o+2] = sp[2];
+            } else {
+                /* per-pixel recolor: expose the warped source color as
+                 * cr/cg/cb (and this pixel's x/y/r/a) to the exprs */
+                v.x = (float)x;
+                float pdx = x - cx, pdy = y - cy;
+                v.r = sqrtf(pdx*pdx + pdy*pdy);
+                v.a = atan2f(pdy, pdx);
+                v.cb = (float)sp[0];   /* BGR order in buffer */
+                v.cg = (float)sp[1];
+                v.cr = (float)sp[2];
+                int rr = (int)expr_eval(&cr_prog, cr_prog.root, &v);
+                int gg = (int)expr_eval(&cg_prog, cg_prog.root, &v);
+                int bb = (int)expr_eval(&cb_prog, cb_prog.root, &v);
+                dst[o]   = clamp_u8(bb);
+                dst[o+1] = clamp_u8(gg);
+                dst[o+2] = clamp_u8(rr);
+            }
         }
     }
     free(grid);
diff --git a/src/frame.c b/src/frame.c
index 260a138..2ed7bb2 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * vcam — Linux virtual webcam pipeline
+ * Copyright (C) 2026 the vcam authors
+ *
+ * This program is free software under the terms of the GNU General
+ * Public License version 2. See the LICENSE file for the full text.
+ */
+
 #include "vcam.h"
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/ipc.c b/src/ipc.c
index 388fdeb..1670f64 100644
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * vcam — Linux virtual webcam pipeline
+ * Copyright (C) 2026 the vcam authors
+ *
+ * This program is free software under the terms of the GNU General
+ * Public License version 2. See the LICENSE file for the full text.
+ */
+
 /*
  * IPC server – Unix domain socket at /tmp/vcam.sock
  *
@@ -244,10 +252,12 @@ static void handle_command(int client_fd, char *line, OverlayRegistry *reg)
             send_line(client_fd, "OK   lightpaint <fade> [<thresh> <huespd>](*) INTERACTIVE painting; thresh 10..120; hue cycle rate");
             send_line(client_fd, "OK   hologram <strength> [<gap> <glitch>](*) sci-fi projection; scanline gap 2..8; glitch rate 0..1");
             send_line(client_fd, "OK   life <density> [<color> <speed>](*) Conway's Life on your edges; color 1=age-rainbow; speed=frames/gen");
-            send_line(client_fd, "OK   mathwarp <amp>                 warp by YOUR math — set with: filter expr <dx> <dy>");
-            send_line(client_fd, "OK                                    vars x y w h t r a; fns sin cos abs sqrt floor");
-            send_line(client_fd, "OK                                    ops + - * / % ; cmp > < >= <= == != ; ternary c?a:b");
+            send_line(client_fd, "OK   mathwarp <amp>                 warp AND recolor by YOUR math");
+            send_line(client_fd, "OK                                    warp:  filter expr <dx> <dy>   (vars x y w h t r a)");
+            send_line(client_fd, "OK                                    color: filter color <r> <g> <b> (adds cr cg cb = src color)");
+            send_line(client_fd, "OK                                    fns sin cos abs sqrt floor; ops + - * / % ; cmp; ternary c?a:b");
             send_line(client_fd, "OK                                    e.g. filter expr (x-w/2)*(sin(t*5)>0?0.08:0) 0");
+            send_line(client_fd, "OK                                         filter color cg cb cr   (swap RGB channels)");
             send_line(client_fd, "OK");
             send_line(client_fd, "OK demoscene & particles:");
             send_line(client_fd, "OK   plasma <blend> [<speed> <scale>](*) classic demoscene plasma over the video, blend 0..0.9");
@@ -379,6 +389,38 @@ static void handle_command(int client_fd, char *line, OverlayRegistry *reg)
             return;
         }
 
+        if (strcmp(sub, "color") == 0) {
+            /* filter color <r-expr> <g-expr> <b-expr>   → recolor pixels
+             * filter color off                          → disable recolor
+             * Each expr returns a channel value 0..255 and may read the
+             * source pixel color as cr cg cb (plus x y w h t r a). */
+            char *rs = strtok_r(NULL, " \t", &save);
+            char *gs = strtok_r(NULL, " \t", &save);
+            char *bs = strtok_r(NULL, " \t", &save);
+            if (rs && !gs && (!strcmp(rs, "off") || !strcmp(rs, "none"))) {
+                mathwarp_clear_color();
+                send_line(client_fd, "OK mathwarp recolor disabled");
+                return;
+            }
+            if (!rs || !gs || !bs) {
+                send_line(client_fd, "ERR usage: filter color <r> <g> <b>   (each 0..255, no spaces in exprs)");
+                send_line(client_fd, "ERR   extra vars: cr cg cb = this pixel's source R/G/B (0..255)");
+                send_line(client_fd, "ERR   plus the usual x y w h t r a; fns sin cos abs sqrt floor; ops + - * / % ?:");
+                send_line(client_fd, "ERR   'filter color off' disables recolor");
+                send_line(client_fd, "ERR   example: filter color cg cb cr   (rotate channels)");
+                return;
+            }
+            char err[128] = "";
+            if (!mathwarp_set_color(rs, gs, bs, err, sizeof err)) {
+                char b[192];
+                snprintf(b, sizeof b, "ERR color expression: %s", err);
+                send_line(client_fd, b);
+                return;
+            }
+            send_line(client_fd, "OK mathwarp recolor updated (needs the 'mathwarp' filter active)");
+            return;
+        }
+
         if (strcmp(sub, "set") == 0) {
             /* Usage:
              *   filter set <index> <param>              → primary
diff --git a/src/main.c b/src/main.c
index 68fcf6c..53e1d0d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * vcam — Linux virtual webcam pipeline
+ * Copyright (C) 2026 the vcam authors
+ *
+ * This program is free software under the terms of the GNU General
+ * Public License version 2. See the LICENSE file for the full text.
+ */
+
 /*
  * vcam – virtual webcam pipeline with runtime control
  *
@@ -6,8 +14,8 @@
  * Pipeline options:
  *   -i <device>   Input webcam device   (default: /dev/video1)
  *   -o <device>   Output v4l2loopback   (default: /dev/video0)
- *   -W <px>       Output width          (default: camera native)
- *   -H <px>       Output height         (default: camera native)
+ *   --res WxH     Output resolution     (default: camera native)
+ *   --list-formats  List supported input resolutions, then exit
  *   -f <fps>      Output frame rate     (default: camera native)
  *
  * Startup overlays (same syntax as IPC 'add' command):
@@ -87,6 +95,21 @@ static int try_wh(char *argv[], int i, int argc, int *w, int *h)
     return 0;
 }
 
+/* Parse a "WxH" string (e.g. "1280x720") into w/h. Returns true on
+ * success. Accepts 'x' or 'X' as the separator. */
+static bool parse_wxh(const char *s, int *w, int *h)
+{
+    char *ep;
+    long ww = strtol(s, &ep, 10);
+    if (ep == s || (*ep != 'x' && *ep != 'X')) return false;
+    const char *hs = ep + 1;
+    long hh = strtol(hs, &ep, 10);
+    if (ep == hs || *ep != '\0') return false;
+    if (ww <= 0 || hh <= 0 || ww > 16384 || hh > 16384) return false;
+    *w = (int)ww; *h = (int)hh;
+    return true;
+}
+
 /* ── main ──────────────────────────────────────── */
 int main(int argc, char *argv[])
 {
@@ -95,6 +118,23 @@ int main(int argc, char *argv[])
     int  width = 0, height = 0, fps = 0;
     bool no_input = false;     /* --no-input: skip webcam capture entirely */
 
+    /* Pre-scan for --list-formats (and the -i that feeds it). This is a
+     * query-and-exit mode, so we handle it before the main parse and
+     * before touching any pipeline state. */
+    {
+        const char *dev = input_dev;
+        for (int i = 1; i < argc; i++) {
+            if (strcmp(argv[i], "-i") == 0 && i+1 < argc)
+                dev = argv[i+1];
+        }
+        for (int i = 1; i < argc; i++) {
+            if (strcmp(argv[i], "--list-formats") == 0 ||
+                strcmp(argv[i], "--list") == 0) {
+                return capture_list_formats(dev) ? 0 : 1;
+            }
+        }
+    }
+
     registry_init(&g_registry);
     filter_chain_init(&g_filters);
 
@@ -106,11 +146,21 @@ int main(int argc, char *argv[])
         } else if (strcmp(argv[i], "-o") == 0 && i+1 < argc) {
             output_dev = argv[++i];
 
+        } else if ((strcmp(argv[i], "--res") == 0 ||
+                    strcmp(argv[i], "-r") == 0) && i+1 < argc) {
+            /* --res WxH : the preferred way to choose resolution.
+             * See 'vcam --list-formats' for what the device supports. */
+            if (!parse_wxh(argv[++i], &width, &height)) {
+                fprintf(stderr, "vcam: bad --res '%s' (expected WxH, "
+                        "e.g. 1280x720)\n", argv[i]);
+                return 1;
+            }
+
         } else if (strcmp(argv[i], "-W") == 0 && i+1 < argc) {
-            width  = atoi(argv[++i]);
+            width  = atoi(argv[++i]);   /* legacy; --res is preferred */
 
         } else if (strcmp(argv[i], "-H") == 0 && i+1 < argc) {
-            height = atoi(argv[++i]);
+            height = atoi(argv[++i]);   /* legacy; --res is preferred */
 
         } else if (strcmp(argv[i], "-f") == 0 && i+1 < argc) {
             fps    = atoi(argv[++i]);
@@ -175,13 +225,13 @@ int main(int argc, char *argv[])
 "vcam – virtual webcam pipeline\n\n"
 "Usage: vcam [OPTIONS]\n\n"
 "Pipeline:\n"
-"  -i <dev>       Input webcam       (default /dev/video1)\n"
-"  -o <dev>       Output loopback    (default /dev/video0)\n"
-"  -W <px>        Width\n"
-"  -H <px>        Height\n"
-"  -f <fps>       Frame rate\n"
-"  --no-input     Don't open a webcam (use screen overlays as source).\n"
-"                 Combine with -W -H and a fullscreen --screen overlay.\n\n"
+"  -i <dev>          Input webcam       (default /dev/video1)\n"
+"  -o <dev>          Output loopback    (default /dev/video0)\n"
+"  --res WxH         Output resolution  (e.g. --res 1280x720)\n"
+"  -f <fps>          Frame rate\n"
+"  --list-formats    List the resolutions the input device supports, then exit\n"
+"  --no-input        Don't open a webcam (use screen overlays as source).\n"
+"                    Combine with --res and a fullscreen --screen overlay.\n\n"
 "Startup overlays:\n"
 "  --img    <id> <x> <y> [<w> [<h>]] <file>\n"
 "  --vid    <id> <x> <y> [<w> [<h>]] <file>\n"
diff --git a/src/output.c b/src/output.c
index 340ba89..75ac2f4 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * vcam — Linux virtual webcam pipeline
+ * Copyright (C) 2026 the vcam authors
+ *
+ * This program is free software under the terms of the GNU General
+ * Public License version 2. See the LICENSE file for the full text.
+ */
+
 /*
  * V4L2 output to v4l2loopback using streaming I/O (MMAP buffers).
  *
diff --git a/src/overlay.c b/src/overlay.c
index f5575bd..36a2090 100644
--- a/src/overlay.c
+++ b/src/overlay.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * vcam — Linux virtual webcam pipeline
+ * Copyright (C) 2026 the vcam authors
+ *
+ * This program is free software under the terms of the GNU General
+ * Public License version 2. See the LICENSE file for the full text.
+ */
+
 #include "vcam.h"
 
 #include <stdio.h>
diff --git a/src/record.c b/src/record.c
index 9fecb2f..14a0271 100644
--- a/src/record.c
+++ b/src/record.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * vcam — Linux virtual webcam pipeline
+ * Copyright (C) 2026 the vcam authors
+ *
+ * This program is free software under the terms of the GNU General
+ * Public License version 2. See the LICENSE file for the full text.
+ */
+
 /*
  * src/record.c — vcam's recording subsystem.
  *
diff --git a/src/registry.c b/src/registry.c
index e9ac86b..0779df1 100644
--- a/src/registry.c
+++ b/src/registry.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * vcam — Linux virtual webcam pipeline
+ * Copyright (C) 2026 the vcam authors
+ *
+ * This program is free software under the terms of the GNU General
+ * Public License version 2. See the LICENSE file for the full text.
+ */
+
 #include "vcam.h"
 #include <string.h>
 #include <stdio.h>
diff --git a/src/test_screen.c b/src/test_screen.c
index 28ecf82..2bddf44 100644
--- a/src/test_screen.c
+++ b/src/test_screen.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-only
+ * vcam — Linux virtual webcam pipeline
+ * Copyright (C) 2026 the vcam authors
+ *
+ * This program is free software under the terms of the GNU General
+ * Public License version 2. See the LICENSE file for the full text.
+ */
+
 /*
  * test_screen – heavy-diagnostic screen capture test
  *