diff --git a/predev/old_but_work.py b/predev/old_but_work.py new file mode 100644 index 0000000..38c78c0 --- /dev/null +++ b/predev/old_but_work.py @@ -0,0 +1,68 @@ +import os +import subprocess +import shutil +import tkinter as tk +from tkinter import filedialog, messagebox + +def process_videos(): + # GUI initialisieren und verstecken + root = tk.Tk() + root.withdraw() + root.attributes('-topmost', True) + + # 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 + + # Pfad zu FFmpeg (bitte prüfen mit 'which ffmpeg') + FFMPEG_PATH = '/opt/homebrew/bin/ffmpeg' + + for path in video_paths: + filename = os.path.basename(path) + + # A) ORIGINAL KOPIEREN + original_dest = os.path.join(output_dir, filename) + try: + shutil.copy2(path, original_dest) + except Exception as e: + print(f"Fehler beim Kopieren: {e}") + + # B) 4:5 CROP ERSTELLEN + new_filename = filename.replace("9x16", "4x5") + + if new_filename == filename: + name_part, ext_part = os.path.splitext(filename) + new_filename = f"{name_part}_4x5{ext_part}" + + # Variable einheitlich benennen: + final_output_path = os.path.join(output_dir, new_filename) + + # Center Crop 4:5 mit Hardware-Beschleunigung + 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', + final_output_path # Hier war der Fehler (out_4_5 existierte nicht) + ], check=True) + except Exception as e: + print(f"Fehler beim Croppen von {filename}: {e}") + + # 3. Finder öffnen und Abschlussmeldung + subprocess.run(['open', output_dir]) + messagebox.showinfo("Erfolg", "Alle Videos wurden verarbeitet!") + +if __name__ == "__main__": + # Unterdrückt die Tk-Warnung im Terminal + os.environ['TK_SILENCE_DEPRECATION'] = '1' + process_videos() diff --git a/predev/requirements.txt b/predev/requirements.txt new file mode 100644 index 0000000..6dc6cca --- /dev/null +++ b/predev/requirements.txt @@ -0,0 +1,8 @@ +altgraph==0.17.5 +macholib==1.16.4 +modulegraph==0.19.7 +packaging==26.2 +py2app==0.28.9 +pyobjc-core==11.1 +pyobjc-framework-Cocoa==11.1 +rumps==0.4.0 diff --git a/predev/setup.py b/predev/setup.py new file mode 100644 index 0000000..f75c48d --- /dev/null +++ b/predev/setup.py @@ -0,0 +1,23 @@ +from setuptools import setup + +APP = ['video_crop.py'] # Name deines Skripts +DATA_FILES = [] +OPTIONS = { + 'argv_emulation': True, + 'packages': ['rumps', 'tkinter'], + 'plist': { + 'LSUIElement': True, # Versteckt die App im Dock, bleibt nur oben + 'CFBundleName': "VideoCropper", + 'CFBundleDisplayName': "Video Cropper", + 'CFBundleGetInfoString': "Crop 9:16 videos to 4:5", + 'CFBundleVersion': "0.1.0", + 'CFBundleShortVersionString': "0.1.0", + } +} + +setup( + app=APP, + data_files=DATA_FILES, + options={'py2app': OPTIONS}, + setup_requires=['py2app'], +) diff --git a/predev/setup_old.py b/predev/setup_old.py new file mode 100644 index 0000000..38415c3 --- /dev/null +++ b/predev/setup_old.py @@ -0,0 +1,23 @@ +from setuptools import setup + +APP = ['old_but_work.py'] # Name deines Skripts +DATA_FILES = [] +OPTIONS = { + 'argv_emulation': True, + 'packages': ['rumps', 'tkinter'], + 'plist': { + 'LSUIElement': True, # Versteckt die App im Dock, bleibt nur oben + 'CFBundleName': "VideoCropper", + 'CFBundleDisplayName': "Video Cropper", + 'CFBundleGetInfoString': "Crop 9:16 videos to 4:5", + 'CFBundleVersion': "0.1.0", + 'CFBundleShortVersionString': "0.1.0", + } +} + +setup( + app=APP, + data_files=DATA_FILES, + options={'py2app': OPTIONS}, + setup_requires=['py2app'], +) diff --git a/predev/video_crop.py b/predev/video_crop.py new file mode 100644 index 0000000..fd018e5 --- /dev/null +++ b/predev/video_crop.py @@ -0,0 +1,64 @@ +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()