Compare commits
15 Commits
c08226952b
...
main
Author | SHA1 | Date | |
---|---|---|---|
1bbe6653d2
|
|||
d32778977c
|
|||
daa353e3ac
|
|||
cf6ae78cd4
|
|||
4b581de6c3
|
|||
48c1b43531
|
|||
de4e7266a0
|
|||
00343ce52d
|
|||
142cf30662
|
|||
0b96dbf448
|
|||
24eb92378d
|
|||
39702c78ab
|
|||
179ebc96d9
|
|||
bea1eaea17
|
|||
e810812f93
|
28
README.md
28
README.md
@ -2,10 +2,18 @@
|
|||||||
|
|
||||||
Shaders for Avidemux with OpenGL support
|
Shaders for Avidemux with OpenGL support
|
||||||
|
|
||||||
## gopro_8:7 - Fisheye removal for GoPro 11+, 8:7 ratio, 60fps, HyperSmooth off
|
## GoPro fisheye removal
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### gopro_8:7 - Fisheye removal for GoPro 11+, 8:7 ratio, 60fps, HyperSmooth off
|
||||||
|
|
||||||
- unfish_gopro_8:7.glsl
|
- unfish_gopro_8:7.glsl
|
||||||
Shader for fisheye removal
|
Shader for fisheye removal
|
||||||
|
|
||||||
|
- preset_gopro_8:7_4K_youtube.py
|
||||||
|
Preset for mp4, 4K, high bitrate
|
||||||
|
|
||||||
- preset_gopro_8:7_4K_2160p.py
|
- preset_gopro_8:7_4K_2160p.py
|
||||||
Preset for mp4, 4K, constant bitrate
|
Preset for mp4, 4K, constant bitrate
|
||||||
|
|
||||||
@ -15,17 +23,21 @@ Preset for mp4, FullHD, constant bitrate
|
|||||||
- preset_gopro_8:7_HD_720p.py
|
- preset_gopro_8:7_HD_720p.py
|
||||||
Preset for mp4, HD, constant bitrate
|
Preset for mp4, HD, constant bitrate
|
||||||
|
|
||||||
- preset_gopro_8:7_QHD_540p.py
|
|
||||||
Preset for mp4, QHD, constant bitrate
|
|
||||||
|
|
||||||
- compute_gopro_8:7.py
|
- compute_gopro_8:7.py
|
||||||
Script to compute output FOV and frame widening
|
Script to compute output FOV and frame widening
|
||||||
|
|
||||||
### Installation for BSD/GNU-Linux systems:
|
### Installation for BSD/GNU-Linux systems:
|
||||||
- Copy the presets to ~/.avidemux6/custom/
|
|
||||||
|
- Copy the presets to ~/.avidemux6/custom/ or ~/.local/share/avidemux6/custom/
|
||||||
- Copy the shader to /opt/rk/avidemux/ (or edit the preset to set the path)
|
- Copy the shader to /opt/rk/avidemux/ (or edit the preset to set the path)
|
||||||
|
|
||||||
Or just run the script install_gopro_8:7.sh
|
Or just run the script install_gopro_8:7.sh
|
||||||
_For commercial OS's, figure out the paths yourself :)_
|
|
||||||
|
_For commercial OS's, figure out the paths yourself, then edit the presets to fix the path to the .glsl file_
|
||||||
|
|
||||||
### Usage:
|
### Usage:
|
||||||
Load and edit video(s), select "Custom/preset_gopro_8:7_..." in the menu and save the video.
|
|
||||||
|
- Load and edit video(s)
|
||||||
|
- Select "Custom/preset_gopro..." in the menu
|
||||||
|
- Add filters
|
||||||
|
- Save the video
|
||||||
|
@ -9,6 +9,7 @@ import math
|
|||||||
|
|
||||||
frame_width = 8
|
frame_width = 8
|
||||||
frame_height = 7
|
frame_height = 7
|
||||||
|
input_ratio = frame_width / frame_height
|
||||||
|
|
||||||
input_vertical_fov = 108.0
|
input_vertical_fov = 108.0
|
||||||
input_diagonal_fov = 156.0
|
input_diagonal_fov = 156.0
|
||||||
@ -20,17 +21,16 @@ output_horizontal_length = math.sqrt((input_diagonal_length ** 2) / (input_verti
|
|||||||
output_diagonal_length = math.hypot(output_horizontal_length, input_vertical_length)
|
output_diagonal_length = math.hypot(output_horizontal_length, input_vertical_length)
|
||||||
output_diagonal_fov = math.degrees(math.atan(output_diagonal_length)) * 2.0
|
output_diagonal_fov = math.degrees(math.atan(output_diagonal_length)) * 2.0
|
||||||
|
|
||||||
output_ratio = output_horizontal_length / input_vertical_length
|
output_ratio = 1.0 / (output_horizontal_length / input_vertical_length)
|
||||||
|
|
||||||
print("Output FOV = %f" % output_diagonal_fov)
|
print("Output FOV = %f" % output_diagonal_fov)
|
||||||
print("Output Ratio = %f" % output_ratio)
|
print("Output Ratio = %f" % output_ratio)
|
||||||
print("= Resolutions =====================")
|
print("= Resolutions =====================")
|
||||||
|
|
||||||
def width_rounded_8(height):
|
def width_rounded_8(height):
|
||||||
width = int(round(height * output_ratio))
|
width = int(round(height * input_ratio))
|
||||||
return ((width + 4) // 8) * 8
|
return ((width + 4) // 8) * 8
|
||||||
|
|
||||||
print("QHD = %i x 540" % width_rounded_8(540))
|
|
||||||
print("HD = %i x 720" % width_rounded_8(720))
|
print("HD = %i x 720" % width_rounded_8(720))
|
||||||
print("Full HD = %i x 1080" % width_rounded_8(1080))
|
print("Full HD = %i x 1080" % width_rounded_8(1080))
|
||||||
print("4K = %i x 2160" % width_rounded_8(2160))
|
print("4K = %i x 2160" % width_rounded_8(2160))
|
||||||
|
@ -91,9 +91,9 @@ adm.addVideoFilter(
|
|||||||
"shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl")
|
"shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl")
|
||||||
adm.addVideoFilter(
|
adm.addVideoFilter(
|
||||||
"swscale",
|
"swscale",
|
||||||
"width=3312",
|
"width=2472",
|
||||||
"height=2160",
|
"height=2160",
|
||||||
"algo=1",
|
"algo=2",
|
||||||
"sourceAR=0",
|
"sourceAR=0",
|
||||||
"targetAR=0",
|
"targetAR=0",
|
||||||
"lockAR=False",
|
"lockAR=False",
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#PY <- Needed to identify #
|
#PY <- Needed to identify #
|
||||||
# RozK
|
# RozK
|
||||||
# Custom preset for GoPro, 8:7 ratio, without hypersmooth, output widened scaled to QHD (540p)
|
# Custom preset for GoPro, 8:7 ratio, without hypersmooth, output widened scaled to 4K (2160p), high bitrate
|
||||||
|
|
||||||
adm = Avidemux()
|
adm = Avidemux()
|
||||||
adm.videoCodec(
|
adm.videoCodec(
|
||||||
"x264",
|
"x264",
|
||||||
"useAdvancedConfiguration=False",
|
"useAdvancedConfiguration=False",
|
||||||
"general.params=CBR=8192",
|
"general.params=CBR=65536",
|
||||||
"general.threads=0",
|
"general.threads=0",
|
||||||
"general.preset=slow",
|
"general.preset=slow",
|
||||||
"general.tuning=film",
|
"general.tuning=film",
|
||||||
@ -91,9 +91,9 @@ adm.addVideoFilter(
|
|||||||
"shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl")
|
"shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl")
|
||||||
adm.addVideoFilter(
|
adm.addVideoFilter(
|
||||||
"swscale",
|
"swscale",
|
||||||
"width=832",
|
"width=2472",
|
||||||
"height=540",
|
"height=2160",
|
||||||
"algo=1",
|
"algo=2",
|
||||||
"sourceAR=0",
|
"sourceAR=0",
|
||||||
"targetAR=0",
|
"targetAR=0",
|
||||||
"lockAR=False",
|
"lockAR=False",
|
@ -91,9 +91,9 @@ adm.addVideoFilter(
|
|||||||
"shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl")
|
"shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl")
|
||||||
adm.addVideoFilter(
|
adm.addVideoFilter(
|
||||||
"swscale",
|
"swscale",
|
||||||
"width=1656",
|
"width=1232",
|
||||||
"height=1080",
|
"height=1080",
|
||||||
"algo=1",
|
"algo=2",
|
||||||
"sourceAR=0",
|
"sourceAR=0",
|
||||||
"targetAR=0",
|
"targetAR=0",
|
||||||
"lockAR=False",
|
"lockAR=False",
|
||||||
|
@ -91,9 +91,9 @@ adm.addVideoFilter(
|
|||||||
"shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl")
|
"shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl")
|
||||||
adm.addVideoFilter(
|
adm.addVideoFilter(
|
||||||
"swscale",
|
"swscale",
|
||||||
"width=1104",
|
"width=824",
|
||||||
"height=720",
|
"height=720",
|
||||||
"algo=1",
|
"algo=2",
|
||||||
"sourceAR=0",
|
"sourceAR=0",
|
||||||
"targetAR=0",
|
"targetAR=0",
|
||||||
"lockAR=False",
|
"lockAR=False",
|
||||||
|
@ -5,32 +5,61 @@
|
|||||||
|
|
||||||
#extension GL_ARB_texture_rectangle: enable
|
#extension GL_ARB_texture_rectangle: enable
|
||||||
|
|
||||||
|
// TODO: investigate
|
||||||
|
// precision highp float;
|
||||||
|
|
||||||
|
// uniforms
|
||||||
uniform sampler2DRect myTextureY;
|
uniform sampler2DRect myTextureY;
|
||||||
uniform sampler2DRect myTextureU;
|
uniform sampler2DRect myTextureU;
|
||||||
uniform sampler2DRect myTextureV;
|
uniform sampler2DRect myTextureV;
|
||||||
uniform vec2 myResolution;
|
uniform vec2 myResolution;
|
||||||
uniform float pts;
|
uniform float pts;
|
||||||
|
|
||||||
const vec2 half_pixel = vec2(0.5, 0.5);
|
// parameters
|
||||||
|
|
||||||
const float input_fov = 156.0;
|
const float input_fov = 156.0;
|
||||||
const float output_fov = 119.789529;
|
const float output_fov = 124.45;
|
||||||
|
const vec2 pixel_scale = vec2(0.652485, 1.0);
|
||||||
|
const int subsampling = 4;
|
||||||
|
|
||||||
vec2 unfish(vec2 coord) {
|
// subsampling constants
|
||||||
float diameter = sqrt(dot(myResolution, myResolution));
|
const float substep = 1.0 / float(subsampling);
|
||||||
vec2 center = myResolution * 0.5;
|
const float substart = substep * 0.5 - 0.5;
|
||||||
vec2 position = coord - center;
|
const float subscale = 1.0 / float(subsampling * subsampling);
|
||||||
float input_distance = length(position);
|
|
||||||
float input_foc = diameter / radians(input_fov);
|
// variables
|
||||||
float output_foc = diameter / (2.0 * tan(radians(output_fov) * 0.5));
|
vec2 center;
|
||||||
return center + position * (input_foc * atan(input_distance / output_foc) / input_distance);
|
float diameter;
|
||||||
|
float input_len;
|
||||||
|
float inv_output_len;
|
||||||
|
|
||||||
|
vec4 unfish(const in vec2 coord) {
|
||||||
|
float len = max(0.001, length(coord));
|
||||||
|
vec2 y_coord = center + coord * ((input_len / len) * atan(len * inv_output_len));
|
||||||
|
vec2 uv_coord = y_coord * 0.5;
|
||||||
|
return vec4(
|
||||||
|
texture2DRect(myTextureY, y_coord).r,
|
||||||
|
texture2DRect(myTextureU, uv_coord).r,
|
||||||
|
texture2DRect(myTextureV, uv_coord).r,
|
||||||
|
1.0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 y_coord = unfish(gl_TexCoord[0].xy + half_pixel);
|
center = myResolution * 0.5;
|
||||||
vec2 uv_coord = y_coord * 0.5;
|
diameter = length(myResolution);
|
||||||
vec4 y = texture2DRect(myTextureY, y_coord);
|
input_len = diameter / radians(input_fov);
|
||||||
vec4 u = texture2DRect(myTextureU, uv_coord);
|
inv_output_len = (2.0 * tan(radians(output_fov * 0.5))) / diameter;
|
||||||
vec4 v = texture2DRect(myTextureV, uv_coord);
|
|
||||||
gl_FragColor = vec4(y.r, u.r, v.r, 1.0);
|
vec2 coord = gl_TexCoord[0].xy - center;
|
||||||
|
vec4 pixel = vec4(0.0, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
float x, y = substart;
|
||||||
|
for (int column = 0; column < subsampling; column++, y += substep) {
|
||||||
|
x = substart;
|
||||||
|
for (int row = 0; row < subsampling; row++, x += substep) {
|
||||||
|
pixel += unfish((coord + vec2(x, y)) * pixel_scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_FragColor = pixel * subscale;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# RozK
|
# RozK
|
||||||
rm -f ~/.avidemux6/custom/preset_gopro_*
|
|
||||||
cp gopro_8:7/preset_gopro_* ~/.avidemux6/custom/
|
if [ -d ~/.local/share/avidemux6 ]; then
|
||||||
sudo mkdir -p /opt/rk
|
mkdir -p ~/.local/share/avidemux6/custom
|
||||||
sudo cp gopro_8:7/unfish_gopro_8:7.glsl /opt/rk/
|
rm -f ~/.local/share/avidemux6/custom/preset_gopro*
|
||||||
|
cp gopro_8:7/preset_gopro* ~/.local/share/avidemux6/custom/
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d ~/.avidemux6 ]; then
|
||||||
|
mkdir -p ~/.avidemux6/custom
|
||||||
|
rm -f ~/.avidemux6/custom/preset_gopro*
|
||||||
|
cp gopro_8:7/preset_gopro* ~/.avidemux6/custom/
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo mkdir -p /opt/rk/avidemux
|
||||||
|
sudo rm -f /opt/rk/avidemux/*
|
||||||
|
sudo cp gopro_8:7/unfish_gopro_8:7.glsl /opt/rk/avidemux
|
||||||
|
Reference in New Issue
Block a user