diff --git a/README.md b/README.md index ae4c16c..28292cd 100644 --- a/README.md +++ b/README.md @@ -26,34 +26,14 @@ Preset for mp4, HD, constant bitrate - compute_gopro_8:7.py Script to compute output FOV and frame widening -### gopro_4:3_maxlens - Fisheye removal for GoPro 11+, 4:3 ratio, Max SuperView, 60fps, HyperSmooth off - -- unfish_gopro_4:3_maxlens.glsl -Shader for fisheye removal - -- preset_gopro_4:3_maxlens_4K_youtube.py -Preset for mp4, 4K, high bitrate - -- preset_gopro_4:3_maxlens_4K_2160p.py -Preset for mp4, 4K, constant bitrate - -- preset_gopro_4:3_maxlens_FullHD_1080p.py -Preset for mp4, FullHD, constant bitrate - -- preset_gopro_4:3_maxlens_HD_720p.py -Preset for mp4, HD, constant bitrate - -- compute_gopro_4:3_maxlens.py -Script to compute output FOV and frame widening - ### 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) -Or just run the scripts install_gopro_8:7.sh and/or install_gopro_4:3_maxlens.sh +Or just run the script install_gopro_8:7.sh -_For commercial OS's, figure out the paths yourself, then edit the presets to fix the path to the .glsl files_ +_For commercial OS's, figure out the paths yourself, then edit the presets to fix the path to the .glsl file_ ### Usage: diff --git a/gopro_4:3_maxlens/compute_gopro_4:3_maxlens.py b/gopro_4:3_maxlens/compute_gopro_4:3_maxlens.py deleted file mode 100644 index c48ae49..0000000 --- a/gopro_4:3_maxlens/compute_gopro_4:3_maxlens.py +++ /dev/null @@ -1,37 +0,0 @@ -# RozK -# Computes fisheye removal parameters for GoPro 11+, 4:3 ratio, Max SuperView, -# keeping the vertical FOV and widening the frame to preserve the diagonal FOV - -# https://www.bobatkins.com/photography/technical/field_of_view.html -# https://community.gopro.com/s/article/HERO11-Black-Mini-Digital-Lenses-FOV-Information?language=fr - -import math - -frame_width = 4 -frame_height = 3 -input_ratio = frame_width / frame_height - -input_vertical_fov = 108.0 -input_diagonal_fov = 169.0 - -input_vertical_length = math.radians(input_vertical_fov * 0.5) -input_diagonal_length = math.radians(input_diagonal_fov * 0.5) - -output_horizontal_length = math.sqrt((input_diagonal_length ** 2) / (input_vertical_length ** 2)) -output_diagonal_length = math.hypot(output_horizontal_length, input_vertical_length) -output_diagonal_fov = math.degrees(math.atan(output_diagonal_length)) * 2.0 - -output_ratio = 8 / 7 -output_pixel_ratio = 1.0 / (output_horizontal_length / input_vertical_length) - -print("Output FOV = %f" % output_diagonal_fov) -print("Output Ratio = %f" % output_pixel_ratio) -print("= Resolutions =====================") - -def width_rounded_8(height): - width = int(round(height * output_ratio)) - return ((width + 4) // 8) * 8 - -print("HD = %i x 720" % width_rounded_8(720)) -print("Full HD = %i x 1080" % width_rounded_8(1080)) -print("4K = %i x 2160" % width_rounded_8(2160)) diff --git a/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_4K_2160p.py b/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_4K_2160p.py deleted file mode 100644 index 8d71f8b..0000000 --- a/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_4K_2160p.py +++ /dev/null @@ -1,116 +0,0 @@ -#PY <- Needed to identify # -# RozK -# Custom preset for GoPro, 4:3 ratio, Max SuperView, without hypersmooth, output widened scaled to 4K (2160p) - -adm = Avidemux() -adm.videoCodec( - "x264", - "useAdvancedConfiguration=False", - "general.params=CBR=32768", - "general.threads=0", - "general.preset=slow", - "general.tuning=film", - "general.profile=high", - "general.fast_decode=False", - "general.zero_latency=False", - "general.fast_first_pass=True", - "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.clearVideoFilters() -adm.addVideoFilter( - "shaderLoader", - "shaderFile=/opt/rk/avidemux/unfish_gopro_4:3_maxlens.glsl") -adm.addVideoFilter( - "swscale", - "width=2472", - "height=2160", - "algo=1", - "sourceAR=0", - "targetAR=0", - "lockAR=False", - "roundup=2") -adm.addVideoFilter( - "MplayerDenoise3DHQ", - "mode=4", - "luma_spatial=4.000000", - "chroma_spatial=3.000000", - "luma_temporal=6.000000", - "chroma_temporal=4.500000") -adm.setContainer( - "MP4", - "muxerType=0", - "optimize=1", - "forceAspectRatio=False", - "aspectRatio=1", - "displayWidth=1280", - "rotation=0", - "clockfreq=0") diff --git a/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_4K_youtube.py b/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_4K_youtube.py deleted file mode 100644 index 65a383c..0000000 --- a/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_4K_youtube.py +++ /dev/null @@ -1,116 +0,0 @@ -#PY <- Needed to identify # -# RozK -# Custom preset for GoPro, 4:3 ratio, Max SuperView, 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=False", - "general.fast_first_pass=True", - "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.clearVideoFilters() -adm.addVideoFilter( - "shaderLoader", - "shaderFile=/opt/rk/avidemux/unfish_gopro_4:3_maxlens.glsl") -adm.addVideoFilter( - "swscale", - "width=2472", - "height=2160", - "algo=1", - "sourceAR=0", - "targetAR=0", - "lockAR=False", - "roundup=2") -adm.addVideoFilter( - "MplayerDenoise3DHQ", - "mode=4", - "luma_spatial=4.000000", - "chroma_spatial=3.000000", - "luma_temporal=6.000000", - "chroma_temporal=4.500000") -adm.setContainer( - "MP4", - "muxerType=0", - "optimize=1", - "forceAspectRatio=False", - "aspectRatio=1", - "displayWidth=1280", - "rotation=0", - "clockfreq=0") diff --git a/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_FullHD_1080p.py b/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_FullHD_1080p.py deleted file mode 100644 index b137bcb..0000000 --- a/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_FullHD_1080p.py +++ /dev/null @@ -1,116 +0,0 @@ -#PY <- Needed to identify # -# RozK -# Custom preset for GoPro, 4:3 ratio, Max SuperView, without hypersmooth, output widened scaled to Full HD (1080p) - -adm = Avidemux() -adm.videoCodec( - "x264", - "useAdvancedConfiguration=False", - "general.params=CBR=16384", - "general.threads=0", - "general.preset=slow", - "general.tuning=film", - "general.profile=high", - "general.fast_decode=False", - "general.zero_latency=False", - "general.fast_first_pass=True", - "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.clearVideoFilters() -adm.addVideoFilter( - "shaderLoader", - "shaderFile=/opt/rk/avidemux/unfish_gopro_4:3_maxlens.glsl") -adm.addVideoFilter( - "swscale", - "width=1232", - "height=1080", - "algo=1", - "sourceAR=0", - "targetAR=0", - "lockAR=False", - "roundup=2") -adm.addVideoFilter( - "MplayerDenoise3DHQ", - "mode=4", - "luma_spatial=4.000000", - "chroma_spatial=3.000000", - "luma_temporal=6.000000", - "chroma_temporal=4.500000") -adm.setContainer( - "MP4", - "muxerType=0", - "optimize=1", - "forceAspectRatio=False", - "aspectRatio=1", - "displayWidth=1280", - "rotation=0", - "clockfreq=0") diff --git a/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_HD_720p.py b/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_HD_720p.py deleted file mode 100644 index c1b0573..0000000 --- a/gopro_4:3_maxlens/preset_gopro_4:3_maxlens_HD_720p.py +++ /dev/null @@ -1,116 +0,0 @@ -#PY <- Needed to identify # -# RozK -# Custom preset for GoPro, 4:3 ratio, Max SuperView, without hypersmooth, output widened scaled to HD (720p) - -adm = Avidemux() -adm.videoCodec( - "x264", - "useAdvancedConfiguration=False", - "general.params=CBR=12288", - "general.threads=0", - "general.preset=slow", - "general.tuning=film", - "general.profile=high", - "general.fast_decode=False", - "general.zero_latency=False", - "general.fast_first_pass=True", - "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.clearVideoFilters() -adm.addVideoFilter( - "shaderLoader", - "shaderFile=/opt/rk/avidemux/unfish_gopro_4:3_maxlens.glsl") -adm.addVideoFilter( - "swscale", - "width=824", - "height=720", - "algo=1", - "sourceAR=0", - "targetAR=0", - "lockAR=False", - "roundup=2") -adm.addVideoFilter( - "MplayerDenoise3DHQ", - "mode=4", - "luma_spatial=4.000000", - "chroma_spatial=3.000000", - "luma_temporal=6.000000", - "chroma_temporal=4.500000") -adm.setContainer( - "MP4", - "muxerType=0", - "optimize=1", - "forceAspectRatio=False", - "aspectRatio=1", - "displayWidth=1280", - "rotation=0", - "clockfreq=0") diff --git a/gopro_4:3_maxlens/unfish_gopro_4:3_maxlens.glsl b/gopro_4:3_maxlens/unfish_gopro_4:3_maxlens.glsl deleted file mode 100644 index c26fd1c..0000000 --- a/gopro_4:3_maxlens/unfish_gopro_4:3_maxlens.glsl +++ /dev/null @@ -1,38 +0,0 @@ -// RozK -// Fisheye removal for GoPro 11+, 4:3 ratio, Max SuperView, without hypersmooth -// Adapted from https://github.com/duducosmos/defisheye -// itself based on http://www.fmwconcepts.com/imagemagick/defisheye/index.php - -#extension GL_ARB_texture_rectangle: enable - -uniform sampler2DRect myTextureY; -uniform sampler2DRect myTextureU; -uniform sampler2DRect myTextureV; -uniform vec2 myResolution; -uniform float pts; - -const vec2 half_pixel = vec2(0.5, 0.5); - -const vec2 input_scale = vec2(0.602294, 1.0); -const float input_fov = 169.0; -const float output_fov = 122.604854; - -vec2 unfish(vec2 coord) { - float diameter = sqrt(dot(myResolution, myResolution)); - vec2 center = myResolution * 0.5; - vec2 input_position = (coord - center) * input_scale; - float input_distance = length(input_position); - float input_len = diameter / radians(input_fov); - float output_len = diameter / (2.0 * tan(radians(output_fov) * 0.5)); - float unfish_ratio = input_len * atan(input_distance / output_len) / input_distance; - return center + input_position * unfish_ratio; -} - -void main() { - vec2 y_coord = unfish(gl_TexCoord[0].xy + half_pixel); - vec2 uv_coord = y_coord * 0.5; - vec4 y = texture2DRect(myTextureY, y_coord); - vec4 u = texture2DRect(myTextureU, uv_coord); - vec4 v = texture2DRect(myTextureV, uv_coord); - gl_FragColor = vec4(y.r, u.r, v.r, 1.0); -} diff --git a/install_gopro_4:3_maxlens.sh b/install_gopro_4:3_maxlens.sh deleted file mode 100755 index ba4d02f..0000000 --- a/install_gopro_4:3_maxlens.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# RozK -rm -f ~/.avidemux6/custom/preset_gopro_4:3_maxlens* -cp gopro_4:3_maxlens/preset_gopro_4:3_maxlens* ~/.avidemux6/custom/ -sudo mkdir -p /opt/rk/avidemux -sudo cp gopro_4:3_maxlens/unfish_gopro_4:3_maxlens.glsl /opt/rk/avidemux