def compress_frames(context: Context): inputs_dir = context.input_frames_dir frame_count = context.frame_count compressed_dir = context.compressed_dir quality_low = context.quality_low extension_type = context.extension_type for x in range(1, frame_count + 1): if os.path.exists(compressed_dir + "compressed_" + str(x) + ".jpg"): continue frame = Frame() frame.load_from_string(inputs_dir + "frame" + str(x) + extension_type) frame.save_image_quality( compressed_dir + "compressed_" + str(x) + ".jpg", quality_low)
def debug_image(block_size, frame_base, list_predictive, list_differences, output_location): logger = logging.getLogger(__name__) predictive_vectors = [] out_image = Frame() out_image.create_new(frame_base.width, frame_base.height) if not list_predictive and not list_differences: logger.info("list_predictive and not list_differences: true") logger.info("Saving inversion image..") out_image.save_image(output_location) return if list_predictive and not list_differences: logger.info("list_predictive and not list_differences") logger.info("saving last image..") out_image.copy_image(frame_base) out_image.save_image(output_location) return # load list into vector displacements for x in range(int(len(list_predictive) / 4)): predictive_vectors.append(DisplacementVector(int(list_predictive[x * 4]), int(list_predictive[x * 4 + 1]), int(list_predictive[x * 4 + 2]), int(list_predictive[x * 4 + 3]))) # copy over predictive vectors into new image for vector in predictive_vectors: out_image.copy_block(frame_base, block_size, vector.x_2, vector.y_2, vector.x_1, vector.y_1) out_image.save_image_quality(output_location, 25)