diff --git a/gopro_8:7/preset_gopro_8:7.py b/gopro_8:7/preset_gopro_8:7.py index f105ae2..e737154 100644 --- a/gopro_8:7/preset_gopro_8:7.py +++ b/gopro_8:7/preset_gopro_8:7.py @@ -88,12 +88,26 @@ adm.videoCodec( 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") + "crop", + "top=80", + "bottom=0", + "left=0", + "right=0", + "ar_select=0") +adm.addVideoFilter( + "swscale", + "width=2880", + "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.audioCodec(0, "LavAAC", "bitrate=192") 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) diff --git a/gopro_8:7/unfish_gopro_8:7.glsl b/gopro_8:7/unfish_gopro_8:7.glsl index 951be4b..a5ae2b8 100644 --- a/gopro_8:7/unfish_gopro_8:7.glsl +++ b/gopro_8:7/unfish_gopro_8:7.glsl @@ -35,6 +35,7 @@ uniform float pts; const vec2 sensor_size = vec2(5.949440, 5.205760); const float equidistant_focal_length = 2.970000; const float rectilinear_focal_length = 2.167601; +const vec2 rectilinear_scale = vec2(1.138819, 1.0); // constants const int subsampling = 4; @@ -49,7 +50,7 @@ vec2 sensor_to_texture; void initialize() { texture_center = myResolution * 0.5; - texture_to_sensor = sensor_size / myResolution; + texture_to_sensor = (sensor_size / myResolution) * rectilinear_scale; #ifdef rotate_180 texture_to_sensor *= -1.0; #endif @@ -68,7 +69,7 @@ vec3 sample_texture(const in vec2 coord) { 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 vec3(16.0 / 255.0, 0.5, 0.5); + return vec3(235.0 / 255.0, 240.0 / 255.0, 240.0 / 255.0); } #endif vec2 uv_coord = y_coord * 0.5; diff --git a/gopro_8:7/unfish_gopro_8:7.py b/gopro_8:7/unfish_gopro_8:7.py index db39b4e..fb848e4 100644 --- a/gopro_8:7/unfish_gopro_8:7.py +++ b/gopro_8:7/unfish_gopro_8:7.py @@ -27,6 +27,9 @@ sensor_pixel_size = 1.12 * 0.001 # mm gopro_array_horizontal = 5312 # p gopro_array_vertical = 4648 # p +gopro_texture_horizontal = 3840 # p +gopro_texture_vertical = 3360 # p + gopro_size_horizontal = gopro_array_horizontal * sensor_pixel_size gopro_size_vertical = gopro_array_vertical * sensor_pixel_size gopro_size_diagonal = math.hypot(gopro_size_horizontal, gopro_size_vertical) @@ -70,12 +73,12 @@ print("linear focal: horizontal = %7.3f, vertical = %7.3f, diagonal = %7.3f (mm) rectilinear_focal_length_vertical, rectilinear_focal_length_diagonal)) -rectilinear_radius = lambda angle, focal_length: focal_length * math.tan(math.radians(angle)) -rectilinear_angle = lambda radius, focal_length: math.degrees(math.atan(radius / focal_length)) +rectilinear_radius = lambda angle: rectilinear_focal_length_vertical * math.tan(math.radians(angle)) +rectilinear_angle = lambda radius: math.degrees(math.atan(radius / rectilinear_focal_length_vertical)) -rectilinear_fov_horizontal = 2.0 * rectilinear_angle(gopro_radius_horizontal, rectilinear_focal_length_vertical) -rectilinear_fov_vertical = 2.0 * rectilinear_angle(gopro_radius_vertical, rectilinear_focal_length_vertical) -rectilinear_fov_diagonal = 2.0 * rectilinear_angle(gopro_radius_diagonal, rectilinear_focal_length_vertical) +rectilinear_fov_horizontal = 2.0 * rectilinear_angle(gopro_radius_horizontal) +rectilinear_fov_vertical = 2.0 * rectilinear_angle(gopro_radius_vertical) +rectilinear_fov_diagonal = 2.0 * rectilinear_angle(gopro_radius_diagonal) print("linear fov : horizontal = %7.3f, vertical = %7.3f, diagonal = %7.3f (deg)" % ( rectilinear_fov_horizontal, @@ -84,23 +87,41 @@ print("linear fov : horizontal = %7.3f, vertical = %7.3f, diagonal = %7.3f (deg print("\n--- shader parameters ---\n") +output_size_horizontal = 2.0 * rectilinear_radius(gopro_fov_horizontal * 0.5) +output_size_vertical = gopro_size_vertical + +output_scale_horizontal = output_size_horizontal / gopro_size_horizontal + print("""// parameters const vec2 sensor_size = vec2(%.6f, %.6f); const float equidistant_focal_length = %.6f; -const float rectilinear_focal_length = %.6f;""" % ( +const float rectilinear_focal_length = %.6f; +const vec2 rectilinear_scale = vec2(%.6F, 1.0);""" % ( gopro_size_horizontal, gopro_size_vertical, gopro_focal_length, - rectilinear_focal_length_vertical) + rectilinear_focal_length_vertical, + output_scale_horizontal) ) -# 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 / gopro_array_vertical) * gopro_array_horizontal * width_scale)) -# -# print("resize: width = %d, height = %d, ratio = %f" % ( -# output_width, -# output_height, -# output_width / output_height)) +print("\n--- filters parameters ---\n") + +output_ratio_horizontal = 4.0 +output_ratio_vertical = 3.0 + +output_crop_ratio = output_ratio_vertical / (output_ratio_horizontal / output_scale_horizontal) + +output_crop_horizontal = gopro_texture_horizontal +output_crop_vertical = output_crop_horizontal * output_crop_ratio + +print("crop : width = %d, height = %d" % ( + output_crop_horizontal, + round(output_crop_vertical))) + +def print_output_array(array_vertical): + array_horizontal = (array_vertical / output_ratio_vertical) * output_ratio_horizontal + print("resize: width = %d, height = %d" % ( + round(array_horizontal / 4.0) * 4, + array_vertical)) + +print_output_array(2160) +print_output_array(1080)