OBS Studio Defish on Linux

If you have a Fish-Eye camera like a GoPro or a generic action cam and you want to correct the distorction is easy to do with KdenLive and similar software but how to do it live with OBS on Linx? I will explain a solution that use shader.


Start OBS and configure Shader

We can load a file that we create as defish.effect

// Based on Sharpness shader of OBS Studio v27.0.0,
// And https://github.com/Oncorporation/obs-shaderfilter/
uniform float4x4 ViewProj;
uniform texture2d image;
uniform float sharpness;
uniform float texture_width;
uniform float texture_height;
sampler_state def_sampler {
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
struct VertData {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
VertData VSDefault(VertData v_in)
VertData vert_out;
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
vert_out.uv = v_in.uv;
return vert_out;
float4 PSDrawBare(VertData v_in) : TARGET
int center_x_percent = 50;
int center_y_percent = 50;
float power = -sharpness;
float2 uv_pixel_interval;
uv_pixel_interval.x = 1.0 / texture_width;
uv_pixel_interval.y = 1.0 / texture_height;
float2 center_pos = float2(center_x_percent * .01, center_y_percent * .01);
float2 uv = v_in.uv;
float b;
if (uv_pixel_interval.x < uv_pixel_interval.y){
b = center_pos.x;
} else {
b = center_pos.y;
uv = center_pos + normalize(v_in.uv - center_pos) * atan(distance(center_pos, v_in.uv) * -power * 10.0) * b / atan(-power * b * 10.0);
return image.Sample(def_sampler, uv);
technique Draw
vertex_shader = VSDefault(v_in);
pixel_shader = PSDrawBare(v_in);

Now you can see under the filter file some paramiters. Scroll to sharpness, it is the paramiter that defish the camera, you can set it experimetally, in my case 0,11.

Set Sharpness on Shader filter

Build (Untested)

git clone https://github.com/Xaymar/obs-StreamFX.git
cd obs-StreamFX
git checkout v0.10
git submodule sync
git submodule update --init --recursive
mkdir BUILD
CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake ../


Enjoy OBS, Linux and Open-Source!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nicola Landro

Linux user and Open Source fun. Deep learning PhD Student, Full stack web developer, Mobile developer, Musitian.