You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.2 KiB
65 lines
2.2 KiB
import os
|
|
import subprocess
|
|
import tkinter as tk
|
|
from tkinter import filedialog, messagebox
|
|
import rumps
|
|
|
|
# Pfad zu FFmpeg (prüfen mit 'which ffmpeg' im Terminal)
|
|
FFMPEG_PATH = '/opt/homebrew/bin/ffmpeg'
|
|
|
|
class VideoCropperApp(rumps.App):
|
|
def __init__(self):
|
|
super(VideoCropperApp, self).__init__("🎬", quit_button="Beenden")
|
|
self.menu = ["Videos verarbeiten"]
|
|
|
|
@rumps.clicked("Videos verarbeiten")
|
|
def process_videos(self, _): # 'self' hinzugefügt und '_' für die rumps-Argumente
|
|
# GUI verstecken
|
|
root = tk.Tk()
|
|
root.withdraw()
|
|
root.attributes('-topmost', True) # Bringt den Dialog nach vorne
|
|
|
|
# 1. Videos auswählen
|
|
video_paths = filedialog.askopenfilenames(
|
|
title="Wähle 9:16 Videos aus",
|
|
filetypes=[("Video files", "*.mp4 *.mov *.m4v")]
|
|
)
|
|
if not video_paths: return
|
|
|
|
# 2. Zielordner wählen
|
|
output_dir = filedialog.askdirectory(title="Wo sollen die Dateien gespeichert werden?")
|
|
if not output_dir: return
|
|
|
|
count = 0
|
|
for path in video_paths:
|
|
base_name = os.path.splitext(os.path.basename(path))[0]
|
|
# Deine Namenslogik: 9x16 durch 4x5 ersetzen
|
|
new_name_4x5 = base_name.replace("9x16", "4x5")
|
|
if new_name_4x5 == base_name:
|
|
new_name_4x5 = f"{base_name}_4x5"
|
|
|
|
out_4x5 = os.path.join(output_dir, f"{new_name_4x5}.mp4")
|
|
|
|
# Center Crop 4:5 mit Hardware-Beschleunigung für Mac
|
|
crop_filter = "crop=iw:iw*1.25:0:(ih-out_h)/2"
|
|
|
|
try:
|
|
subprocess.run([
|
|
FFMPEG_PATH, '-i', path,
|
|
'-vf', crop_filter,
|
|
'-c:v', 'h264_videotoolbox', '-b:v', '10M',
|
|
'-c:a', 'copy', '-y',
|
|
out_4x5
|
|
], check=True)
|
|
count += 1
|
|
except Exception as e:
|
|
print(f"Fehler: {e}")
|
|
|
|
# 3. Abschluss
|
|
subprocess.run(['open', output_dir])
|
|
rumps.notification("Video Cropper", "Fertig", f"{count} Videos konvertiert.")
|
|
messagebox.showinfo("Erfolg", f"{count} Videos wurden verarbeitet!")
|
|
|
|
if __name__ == "__main__":
|
|
VideoCropperApp().run()
|