focal length, preset and license
This commit is contained in:
		
							
								
								
									
										112
									
								
								gopro_8:7/preset_gopro_8:7.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								gopro_8:7/preset_gopro_8:7.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,112 @@
 | 
			
		||||
#PY  <- Needed to identify #
 | 
			
		||||
# RozK
 | 
			
		||||
# Custom preset for GoPro, 8:7 ratio, without hypersmooth, output widened scaled to 4K (2160p), high bitrate
 | 
			
		||||
 | 
			
		||||
adm = Avidemux()
 | 
			
		||||
adm.videoCodec(
 | 
			
		||||
    "x264",
 | 
			
		||||
    "useAdvancedConfiguration=False",
 | 
			
		||||
    "general.params=CBR=65536",
 | 
			
		||||
    "general.threads=0",
 | 
			
		||||
    "general.preset=slow",
 | 
			
		||||
    "general.tuning=film",
 | 
			
		||||
    "general.profile=high",
 | 
			
		||||
    "general.fast_decode=False",
 | 
			
		||||
    "general.zero_latency=True",
 | 
			
		||||
    "general.fast_first_pass=False",
 | 
			
		||||
    "general.blueray_compatibility=False",
 | 
			
		||||
    "general.fake_interlaced=False",
 | 
			
		||||
    "level=-1",
 | 
			
		||||
    "vui.sar_height=1",
 | 
			
		||||
    "vui.sar_width=1",
 | 
			
		||||
    "vui.overscan=0",
 | 
			
		||||
    "vui.vidformat=5",
 | 
			
		||||
    "vui.fullrange=False",
 | 
			
		||||
    "vui.colorprim=2",
 | 
			
		||||
    "vui.transfer=2",
 | 
			
		||||
    "vui.colmatrix=2",
 | 
			
		||||
    "vui.chroma_loc=0",
 | 
			
		||||
    "MaxRefFrames=3",
 | 
			
		||||
    "MinIdr=25",
 | 
			
		||||
    "MaxIdr=250",
 | 
			
		||||
    "i_scenecut_threshold=40",
 | 
			
		||||
    "intra_refresh=False",
 | 
			
		||||
    "MaxBFrame=3",
 | 
			
		||||
    "i_bframe_adaptive=1",
 | 
			
		||||
    "i_bframe_bias=0",
 | 
			
		||||
    "i_bframe_pyramid=2",
 | 
			
		||||
    "b_deblocking_filter=True",
 | 
			
		||||
    "i_deblocking_filter_alphac0=0",
 | 
			
		||||
    "i_deblocking_filter_beta=0",
 | 
			
		||||
    "cabac=True",
 | 
			
		||||
    "interlaced=False",
 | 
			
		||||
    "constrained_intra=False",
 | 
			
		||||
    "tff=True",
 | 
			
		||||
    "fake_interlaced=False",
 | 
			
		||||
    "analyze.b_8x8=True",
 | 
			
		||||
    "analyze.b_i4x4=True",
 | 
			
		||||
    "analyze.b_i8x8=True",
 | 
			
		||||
    "analyze.b_p8x8=True",
 | 
			
		||||
    "analyze.b_p16x16=False",
 | 
			
		||||
    "analyze.b_b16x16=False",
 | 
			
		||||
    "analyze.weighted_pred=2",
 | 
			
		||||
    "analyze.weighted_bipred=True",
 | 
			
		||||
    "analyze.direct_mv_pred=1",
 | 
			
		||||
    "analyze.chroma_offset=0",
 | 
			
		||||
    "analyze.me_method=1",
 | 
			
		||||
    "analyze.me_range=16",
 | 
			
		||||
    "analyze.mv_range=-1",
 | 
			
		||||
    "analyze.mv_range_thread=-1",
 | 
			
		||||
    "analyze.subpel_refine=7",
 | 
			
		||||
    "analyze.chroma_me=True",
 | 
			
		||||
    "analyze.mixed_references=True",
 | 
			
		||||
    "analyze.trellis=1",
 | 
			
		||||
    "analyze.psy_rd=1.000000",
 | 
			
		||||
    "analyze.psy_trellis=0.000000",
 | 
			
		||||
    "analyze.fast_pskip=True",
 | 
			
		||||
    "analyze.dct_decimate=True",
 | 
			
		||||
    "analyze.noise_reduction=0",
 | 
			
		||||
    "analyze.psy=True",
 | 
			
		||||
    "analyze.intra_luma=11",
 | 
			
		||||
    "analyze.inter_luma=21",
 | 
			
		||||
    "ratecontrol.rc_method=0",
 | 
			
		||||
    "ratecontrol.qp_constant=0",
 | 
			
		||||
    "ratecontrol.qp_min=10",
 | 
			
		||||
    "ratecontrol.qp_max=51",
 | 
			
		||||
    "ratecontrol.qp_step=4",
 | 
			
		||||
    "ratecontrol.bitrate=0",
 | 
			
		||||
    "ratecontrol.rate_tolerance=1.000000",
 | 
			
		||||
    "ratecontrol.vbv_max_bitrate=0",
 | 
			
		||||
    "ratecontrol.vbv_buffer_size=0",
 | 
			
		||||
    "ratecontrol.vbv_buffer_init=1",
 | 
			
		||||
    "ratecontrol.ip_factor=1.400000",
 | 
			
		||||
    "ratecontrol.pb_factor=1.300000",
 | 
			
		||||
    "ratecontrol.aq_mode=1",
 | 
			
		||||
    "ratecontrol.aq_strength=1.000000",
 | 
			
		||||
    "ratecontrol.mb_tree=True",
 | 
			
		||||
    "ratecontrol.lookahead=40")
 | 
			
		||||
adm.addVideoFilter(
 | 
			
		||||
    "shaderLoader", "shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl")
 | 
			
		||||
adm.addVideoFilter(
 | 
			
		||||
    "swscale", "width=2792", "height=2160", "algo=2", "sourceAR=0", "targetAR=0", "lockAR=False", "roundup=0")
 | 
			
		||||
adm.audioClearTracks()
 | 
			
		||||
if adm.audioTotalTracksCount() <= 0:
 | 
			
		||||
    raise("Cannot add audio track 0, total tracks: " + str(adm.audioTotalTracksCount()))
 | 
			
		||||
adm.audioAddTrack(0)
 | 
			
		||||
adm.audioCodec(0, "LavAAC", "bitrate=128")
 | 
			
		||||
adm.audioSetDrc2(0, 1, 1, 0.001, 0.2, 1, 2, -12)
 | 
			
		||||
adm.audioSetEq(0, 0, 0, 0, 0, 880, 5000)
 | 
			
		||||
adm.audioSetChannelGains(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 | 
			
		||||
adm.audioSetChannelDelays(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 | 
			
		||||
adm.audioSetChannelRemap(0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8)
 | 
			
		||||
adm.audioSetShift(0, 0, 0)
 | 
			
		||||
adm.audioSetNormalize2(0, 1, 10, -30)
 | 
			
		||||
adm.setContainer(
 | 
			
		||||
    "MP4",
 | 
			
		||||
    "muxerType=0",
 | 
			
		||||
    "optimize=1",
 | 
			
		||||
    "forceAspectRatio=False",
 | 
			
		||||
    "aspectRatio=1",
 | 
			
		||||
    "displayWidth=1280",
 | 
			
		||||
    "rotation=0",
 | 
			
		||||
    "clockfreq=0")
 | 
			
		||||
@ -1,13 +1,26 @@
 | 
			
		||||
#version 130
 | 
			
		||||
// RozK
 | 
			
		||||
// Fisheye removal for GoPro 11+, 8:7 ratio, without hypersmooth
 | 
			
		||||
// Copyright (C) 2025 Jean-Baptiste Berlioz
 | 
			
		||||
//
 | 
			
		||||
// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
// it under the terms of the GNU Affero General Public License as
 | 
			
		||||
// published by the Free Software Foundation, either version 3 of the
 | 
			
		||||
// License, or (at your option) any later version.
 | 
			
		||||
//
 | 
			
		||||
// This program is distributed in the hope that it will be useful,
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
// GNU Affero General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU Affero General Public License
 | 
			
		||||
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
#extension GL_ARB_texture_rectangle: enable
 | 
			
		||||
 | 
			
		||||
#undef highp // defined by Qt-OpenGl
 | 
			
		||||
#define rotate_180
 | 
			
		||||
//#define debug_borders
 | 
			
		||||
 | 
			
		||||
#undef highp // defined by Qt-OpenGl
 | 
			
		||||
precision highp float;
 | 
			
		||||
 | 
			
		||||
// uniforms
 | 
			
		||||
@ -19,9 +32,8 @@ uniform float pts;
 | 
			
		||||
 | 
			
		||||
// parameters
 | 
			
		||||
const vec2 sensor_size = vec2(5.949440, 5.205760);
 | 
			
		||||
const vec2 pixel_scale = vec2(0.871558, 1.0);
 | 
			
		||||
const float equidistant_focal_length = 2.920000;
 | 
			
		||||
const float rectilinear_focal_length = 2.102263;
 | 
			
		||||
const float equidistant_focal_length = 3.020000;
 | 
			
		||||
const float rectilinear_focal_length = 2.232346;
 | 
			
		||||
 | 
			
		||||
// constants
 | 
			
		||||
const int subsampling = 4;
 | 
			
		||||
@ -36,39 +48,34 @@ vec2 sensor_to_texture;
 | 
			
		||||
 | 
			
		||||
void initialize() {
 | 
			
		||||
    texture_center = myResolution * 0.5;
 | 
			
		||||
    texture_to_sensor = (sensor_size / myResolution) * pixel_scale;
 | 
			
		||||
    texture_to_sensor = sensor_size / myResolution;
 | 
			
		||||
#ifdef rotate_180
 | 
			
		||||
    texture_to_sensor *= -1.0;
 | 
			
		||||
#endif
 | 
			
		||||
    sensor_to_texture = (myResolution / sensor_size);
 | 
			
		||||
    sensor_to_texture = myResolution / sensor_size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
vec2 unfish_coord(const in vec2 coord) {
 | 
			
		||||
vec2 equidistant_to_rectilinear(const in vec2 coord) {
 | 
			
		||||
    float rectilinear_radius = length(coord);
 | 
			
		||||
    float rectilinear_angle = atan(rectilinear_radius / rectilinear_focal_length);
 | 
			
		||||
    float equidistant_radius = rectilinear_angle * equidistant_focal_length;
 | 
			
		||||
    return coord * (equidistant_radius / rectilinear_radius);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
vec4 unfish_pixel(const in vec2 coord) {
 | 
			
		||||
    vec2 unfished = unfish_coord((coord - texture_center) * texture_to_sensor);
 | 
			
		||||
    vec2 y_coord = texture_center + unfished * sensor_to_texture;
 | 
			
		||||
 | 
			
		||||
    // y_coord.y = coord.y;
 | 
			
		||||
 | 
			
		||||
vec4 sample_texture(const in vec2 coord) {
 | 
			
		||||
    vec2 rectilinear = equidistant_to_rectilinear((coord - texture_center) * texture_to_sensor);
 | 
			
		||||
    vec2 y_coord = texture_center + rectilinear * sensor_to_texture;
 | 
			
		||||
#ifdef debug_borders
 | 
			
		||||
    if (y_coord.x < 0.0 || y_coord.y < 0.0 || y_coord.x > myResolution.x || y_coord.y > myResolution.y) {
 | 
			
		||||
        return vec4(1.0);
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
    );
 | 
			
		||||
        texture2DRect(myTextureY, y_coord).x,
 | 
			
		||||
        texture2DRect(myTextureU, uv_coord).x,
 | 
			
		||||
        texture2DRect(myTextureV, uv_coord).x,
 | 
			
		||||
        1.0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void main() {
 | 
			
		||||
@ -80,7 +87,7 @@ void main() {
 | 
			
		||||
    for (int y = 0; y < subsampling; y++) {
 | 
			
		||||
        for (int x = 0; x < subsampling; x++) {
 | 
			
		||||
            vec2 offset = subsampling_start + subsampling_step * vec2(x, y);
 | 
			
		||||
            pixel += unfish_pixel(coord + offset);
 | 
			
		||||
            pixel += sample_texture(coord + offset);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,18 @@
 | 
			
		||||
# RozK
 | 
			
		||||
# Fisheye removal for GoPro 11+, 8:7 ratio, without hypersmooth
 | 
			
		||||
# Copyright (C) 2025 Jean-Baptiste Berlioz
 | 
			
		||||
#
 | 
			
		||||
# This program is free software: you can redistribute it and/or modify
 | 
			
		||||
# it under the terms of the GNU Affero General Public License as
 | 
			
		||||
# published by the Free Software Foundation, either version 3 of the
 | 
			
		||||
# License, or (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
# This program is distributed in the hope that it will be useful,
 | 
			
		||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
# GNU Affero General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
# You should have received a copy of the GNU Affero General Public License
 | 
			
		||||
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
import math
 | 
			
		||||
 | 
			
		||||
@ -38,7 +52,7 @@ print("gopro  size : horizontal = %7.3f, vertical = %7.3f, diagonal = %7.3f (mm)
 | 
			
		||||
 | 
			
		||||
# https://thinglabs.io/gopro-focal-radius-guide
 | 
			
		||||
 | 
			
		||||
gopro_focal_length = 2.92 # mm
 | 
			
		||||
gopro_focal_length = 3.02 # mm
 | 
			
		||||
 | 
			
		||||
gopro_radius_horizontal = gopro_size_horizontal * 0.5
 | 
			
		||||
gopro_radius_vertical   = gopro_size_vertical   * 0.5
 | 
			
		||||
@ -84,19 +98,23 @@ print("linear fov  : horizontal = %7.3f, vertical = %7.3f, diagonal = %7.3f (deg
 | 
			
		||||
 | 
			
		||||
print("\n--- shader parameters ---\n")
 | 
			
		||||
 | 
			
		||||
rectilinear_angle_horizontal = rectilinear_angle(gopro_radius_horizontal,       rectilinear_focal_length_horizontal)
 | 
			
		||||
preserved_radius_horizontal  = rectilinear_radius(rectilinear_angle_horizontal, rectilinear_focal_length_vertical)
 | 
			
		||||
 | 
			
		||||
pixel_scale = gopro_radius_horizontal / preserved_radius_horizontal
 | 
			
		||||
 | 
			
		||||
print("""// parameters
 | 
			
		||||
const vec2 sensor_size = vec2(%.6f, %.6f);
 | 
			
		||||
const vec2 pixel_scale = vec2(%.6f, 1.0);
 | 
			
		||||
const float equidistant_focal_length = %.6f;
 | 
			
		||||
const float rectilinear_focal_length = %.6f;
 | 
			
		||||
""" % (
 | 
			
		||||
    gopro_size_horizontal, gopro_size_vertical,
 | 
			
		||||
    pixel_scale,
 | 
			
		||||
    gopro_focal_length,
 | 
			
		||||
    rectilinear_focal_length_vertical)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
print("\n--- filter parameters 4K ---\n")
 | 
			
		||||
 | 
			
		||||
width_scale = rectilinear_focal_length_vertical / rectilinear_focal_length_horizontal
 | 
			
		||||
 | 
			
		||||
output_height = 2160
 | 
			
		||||
output_width  = int(round((output_height / 7.0) * 8.0 * width_scale))
 | 
			
		||||
 | 
			
		||||
print("resize: width = %d, height = %d" % (
 | 
			
		||||
    output_width,
 | 
			
		||||
    output_height))
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user