gyroflow / gyroflow-ofx

GNU General Public License v3.0
105 stars 7 forks source link

Edit default parameters for plugin #57

Open marcuskjellberg opened 6 months ago

marcuskjellberg commented 6 months ago

It would be great if the plugin could read the same file (default.gyroflow) with defaults as the main app. Using a preset would save me a lot of time

Shadetail commented 3 months ago

I worked around this by making a python script that batch applies a preset to a bunch of videos at once by drag and dropping the videos onto the script:

import subprocess
import os
import sys

# Paths to Gyroflow and the preset file
gyroflow_path = r"C:\Program Files\Gyroflow 1.5.4\Gyroflow.exe"
preset_path = r"D:\Projects\Gyroflow\GoPro11FOV15NoZoom_5312x2988.gyroflow"

def modify_preset(output_folder):
    # Normalize the output folder path for the preset file
    normalized_output_folder = output_folder.replace("\\", "/")

    try:
        print(f"Attempting to read from preset file: {preset_path}")
        with open(preset_path, 'r') as file:
            lines = file.readlines()

        print(f"Attempting to update output folder in preset data to: {normalized_output_folder}")
        with open(preset_path, 'w') as file:
            for line in lines:
                if '"output_folder":' in line:
                    # Update the line with the new output folder path
                    new_line = f'        "output_folder": "file:///{normalized_output_folder}",\n'
                    file.write(new_line)
                else:
                    file.write(line)
        print("Successfully wrote updates to preset file.")
    except Exception as e:
        print(f"Error during preset modification: {e}")

for video_file in sys.argv[1:]:
    print(f"Processing file: {video_file}")
    video_directory = os.path.dirname(video_file)
    modify_preset(video_directory)

    # Call Gyroflow with the updated preset and the current video file
    try:
        subprocess.call([gyroflow_path, video_file, "--preset", preset_path, "--export-project", "1"])
    except Exception as e:
        print(f"Error calling Gyroflow: {e}")

# Pause the script at the end to read errors
input("Press Enter to exit...")

That creates a .gyroflow file next to each video file.

Then I made an autohotkey script:

F1::  ; Press F1 to start the loop
Loop
{
    Send, +v  ; Shift+v
    Sleep, 150  
    Send, {Down}  ; Down arrow
    Sleep, 150  
    Send, {Left}  ; Left arrow
    Sleep, 150
    Click  ; Left mouse click
    Sleep, 250
    Send, {Right}  ; Right arrow
    Sleep, 150
}
return

F2::ExitApp  ; Press F2 to terminate the script immediately

I place all of my videos into a single timeline, after each other, and add Gyroflow ofx to all of them. Then I activate the autohotkey script, place my mouse cursor on the "Load for current file" button and press F1. As soon as all videos have their profile loaded I press F2 to terminate the script.