Free Core now2sdk v0.2.4 Core is free for commercial use with zero license key required
Docs Hub SDK Modules Release Notes Pricing Contact GitHub
Download Free SDK →
Router / GPU Video Free Core Module Summary →

LVideoFilter Reference Manual & GPU Video Shader Pipeline

Header#include "LVideoFilter.h"
HierarchyLObject, LSink (OpenGL FBO + PBO)
LicenseFree Core
TargetsLinux x64 · Win64 · C++17

LVideoFilter is a GPU-accelerated OpenGL video processing node derived from both LObject and LSink. It replaces CPU-bound FFmpeg video filter graphs with a dedicated offscreen GLSL pipeline (supporting direct YUV420P, YUV422P, NV12, UYVY422, YUYV422, BGRA, and RGBA uploads) that can be placed anywhere in the pipeline, such as LLive -> LVideoFilter -> LColor -> LMixer -> LOutput.

Note: For simple input-level orientation and deinterlacing (e.g. LLive -> LPreview without intermediate nodes), LLive and LFile also run the exact same GPU shader natively via setProps("hflip", true) and setProps("deinterlace", true).


1. Architectural Concept & Orientation Safety

graph LR
    SRC[LLive / LFile / LMixer / LColor] -->|setSource| VF[LVideoFilter]
    VF -->|All Filters Off or Progressive Bypass| PASS[Zero-Copy Passthrough]
    VF -->|Active GPU Effect| GL[Offscreen OpenGL 1:1 Quad Shader + PBO Readback]
    GL --> DOWN[LColor / LMixer / LSwitcher / LOutput / LRecorder]

2. Typed Filter Props Structs

struct LDeinterlaceProps {
    bool force = false; // If false, deinterlaces only frames marked interlaced
};

Configures GPU edge-based line average (ELA) deinterlacing ("deinterlace").

struct LBlurProps {
    float radius = 2.0f; // Soft blur radius in pixels (0.0..10.0)
};

struct LSharpenProps {
    float amount = 0.5f; // Unsharp mask intensity (0.0..2.0)
};

struct LVignetteProps {
    float strength = 0.5f; // Edge darkening intensity (0.0..1.0)
};

Configures GPU blur ("blur"), unsharp mask ("sharpen"), and radial vignette ("vignette").


3. API Reference & Key Methods

void setSource(LObject* source);
LObject* getSource() const;
void setEnabled(bool enabled);
bool isEnabled() const;

Attaches an upstream LObject source and enables or bypasses GPU video filtering.

void setProps(const std::string& key, bool enabled);
void setProps(const std::string& key, const std::string& value);
bool isFilterEnabled(const std::string& key) const;
std::string getProps(const std::string& key) const;

Enables or disables GPU stages cleanly without altering stored parameter values. Supported keys: "enabled", "hflip" (alias "mirror"), "vflip", "deinterlace", "blur", "sharpen", "vignette", "negate", "grayscale".

void updateFilter(const LDeinterlaceProps& props);
void updateFilter(const LBlurProps& props);
void updateFilter(const LSharpenProps& props);
void updateFilter(const LVignetteProps& props);
// Matching getFilter(...) overloads read current values back.

Updates parameter values without changing enable flags. Immediately re-renders the last paused frame if that stage is active.

void reset();
bool hasActiveFilters() const;

Disables all active stages and restores default struct parameters.


4. C++ Pipeline Example

#include "now2sdk.h"

int main() {
    LLive* cam = new LLive();
    cam->DeviceSet(0);
    cam->Start();

    // Pipeline: LLive -> LVideoFilter -> LColor -> LMixer -> LOutput
    LVideoFilter* vf = new LVideoFilter();
    vf->setSource(cam);

    // Update effect values via structs
    LSharpenProps sharpen;
    sharpen.amount = 0.35f;
    vf->updateFilter(sharpen);

    LVignetteProps vig;
    vig.strength = 0.40f;
    vf->updateFilter(vig);

    // Toggle stages via setProps
    vf->setProps("hflip", true);
    vf->setProps("deinterlace", true);
    vf->setProps("sharpen", true);
    vf->setProps("vignette", true);

    LColor* color = new LColor();
    color->setSource(vf);

    LPreview* preview = new LPreview();
    preview->setProps("ui_framework", "qt");
    preview->previewEnable(nullptr, false, true);
    preview->previewObject(color);

    return 0;
}