prüfe mein skript und behebe alle fehler darin. nenne es mir anschließend vollständig mit dme gesamten code der anwendung. 

C:\Users\Admin>C:/Users/Admin/AppData/Local/Programs/Python/Python310/python.exe d:/_Projekte/_MyCodes/VideoSplitter_v2.py
Exception ignored in: <function FFMPEG_AudioReader.__del__ at 0x0000024AF8026950>
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\readers.py", line 254, in __del__
    self.close_proc()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\readers.py", line 149, in close_proc
    self.proc.terminate()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1571, in terminate
    _winapi.TerminateProcess(self._handle, 1)
OSError: [WinError 6] Das Handle ist ungültig
Exception ignored in: <function FFMPEG_AudioReader.__del__ at 0x0000024AF8026950>
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\readers.py", line 254, in __del__
    self.close_proc()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\readers.py", line 149, in close_proc
    self.proc.terminate()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1571, in terminate
    _winapi.TerminateProcess(self._handle, 1)
OSError: [WinError 6] Das Handle ist ungültig
Exception ignored in: <function FFMPEG_AudioReader.__del__ at 0x0000024AF8026950>
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\readers.py", line 254, in __del__
    self.close_proc()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\readers.py", line 149, in close_proc
    self.proc.terminate()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1571, in terminate
    _winapi.TerminateProcess(self._handle, 1)
OSError: [WinError 6] Das Handle ist ungültig


import os
import threading
import tkinter as tk
from tkinter import filedialog, ttk
from moviepy.video.io.VideoFileClip import VideoFileClip
import queue
import datetime
import concurrent.futures

class VideoSplitterApp:
    def __init__(self, root):
        self.root = root
        self.root.title('Video Splitter')
        self.root.geometry('600x600')
        self.input_file = ''
        self.output_folder = ''
        self.max_duration = 60  # Standard maximale Clip-Dauer in Sekunden
        self.quality = 'Same as original'  # Standardqualität
        self.progress_value = 0  # Fortschrittswert zur Aktualisierung
        self.total_clips = 0
        self.processed_clips = 0
        self.create_widgets()

    def create_widgets(self):
        input_frame = tk.Frame(self.root)
        input_frame.pack(pady=10, fill='x')

        self.input_label = tk.Label(input_frame, text='No video selected')
        self.input_label.pack(side='left', padx=5)

        self.select_input_button = tk.Button(
            input_frame, text='Select Video', command=self.select_input_video)
        self.select_input_button.pack(side='right', padx=5)

        duration_frame = tk.Frame(self.root)
        duration_frame.pack(pady=10, fill='x')

        duration_label = tk.Label(duration_frame, text='Max clip duration (seconds):')
        duration_label.pack(side='left', padx=5)

        self.duration_spinbox = tk.Spinbox(duration_frame, from_=1, to=3600, width=5)
        self.duration_spinbox.delete(0, 'end')
        self.duration_spinbox.insert(0, '60')
        self.duration_spinbox.pack(side='right', padx=5)

        output_frame = tk.Frame(self.root)
        output_frame.pack(pady=10, fill='x')

        self.output_label = tk.Label(output_frame, text='Output folder not selected')
        self.output_label.pack(side='left', padx=5)

        self.select_output_button = tk.Button(
            output_frame, text='Select Output Folder', command=self.select_output_folder)
        self.select_output_button.pack(side='right', padx=5)

        quality_frame = tk.Frame(self.root)
        quality_frame.pack(pady=10, fill='x')

        quality_label = tk.Label(quality_frame, text='Output Quality:')
        quality_label.pack(side='left', padx=5)

        self.quality_combo = ttk.Combobox(
            quality_frame, values=['Same as original', 'Low', 'Medium', 'High', 'Hardware Accelerated'], state='readonly')
        self.quality_combo.current(0)
        self.quality_combo.pack(side='right', padx=5)

        progress_frame = tk.Frame(self.root)
        progress_frame.pack(pady=10, fill='x')

        self.progress_var = tk.DoubleVar()
        self.progress_bar = ttk.Progressbar(progress_frame, variable=self.progress_var, maximum=100)
        self.progress_bar.pack(fill='x', padx=5)

        console_frame = tk.Frame(self.root)
        console_frame.pack(pady=10, fill='both', expand=True)

        console_label = tk.Label(console_frame, text='Console Output:')
        console_label.pack(side='top', anchor='w')

        self.console_text = tk.Text(console_frame, height=10)
        self.console_text.pack(fill='both', padx=5, pady=5, expand=True)

        start_frame = tk.Frame(self.root)
        start_frame.pack(pady=20)

        self.start_button = tk.Button(start_frame, text='Start', command=self.start_splitting)
        self.start_button.pack()

    def select_input_video(self):
        filetypes = [('Video files', '*.mp4;*.avi;*.mov;*.mkv')]
        file_name = filedialog.askopenfilename(title='Select Video File', filetypes=filetypes)
        if file_name:
            self.input_file = file_name
            self.input_label.config(text=f"Selected: {os.path.basename(file_name)}")
            self.output_folder = os.path.dirname(file_name)
            self.output_label.config(text=f"Output Folder : {os.path.basename(self.output_folder)}")

    def select_output_folder(self):
        folder_name = filedialog.askdirectory(title='Select Output Folder')
        if folder_name:
            self.output_folder = folder_name
            self.output_label.config(text=f"Output Folder: {os.path.basename(folder_name)}")

    def start_splitting(self):
        self.max_duration = int(self.duration_spinbox.get())
        self.quality = self.quality_combo.get()
        self.progress_value = 0
        self.processed_clips = 0
        self.console_text.delete(1.0, 'end')
        self.start_button.config(state='disabled')
        self.queue = queue.Queue()
        self.worker_thread = threading.Thread(target=self.split_video)
        self.worker_thread.start()
        self.update_progress()

    def update_progress(self):
        try:
            while True:
                message_type, message = self.queue.get_nowait()
                if message_type == "message":
                    self.log_message(message)
                elif message_type == "done":
                    self.start_button.config(state='normal')
                    return
        except queue.Empty:
            pass

        self.progress_var.set(self.progress_value)
        self.root.after(100, self.update_progress)

    def log_message(self, message):
        timestamp = datetime.datetime.now().strftime("%H:%M:%S")
        self.console_text.insert(tk.END, f"[{timestamp}] {message}")
        self.console_text.see(tk.END)

    def split_video(self):
        try:
            video = VideoFileClip(self.input_file)
            duration = video.duration
            max_duration = self.max_duration
            base_name = os.path.splitext(os.path.basename(self.input_file))[0]
            extension = os.path.splitext(self.input_file)[1]

            quality_settings = {
                'Same as original': {'codec': 'libx264'},
                'Low': {'codec': 'libx264', 'preset': 'ultrafast', 'bitrate': '500k'},
                'Medium': {'codec': 'libx264', 'preset': 'medium', 'bitrate': '1000k'},
                'High': {'codec': 'libx264', 'preset': 'slow', 'bitrate': '2000k'},
                'Hardware Accelerated': {'codec': 'h264_nvenc', 'preset': 'fast', 'bitrate': '5000k'}
            }

            self.total_clips = int(duration // max_duration) + (1 if duration % max_duration > 0 else 0)

            clips = []
            for i in range(self.total_clips):
                start_time = i * max_duration
                end_time = min(start_time + max_duration, duration)
                output_file = f"{base_name}_part{i+1}{extension}"
                output_path = os.path.join(self.output_folder, output_file)
                clips.append((start_time, end_time, output_path, i))

            with concurrent.futures.ThreadPoolExecutor() as executor:
                futures = [
                    executor.submit(self.process_clip, clip_info, quality_settings[self.quality], i) for i, clip_info in enumerate(clips)
                ]
                for future in concurrent.futures.as_completed(futures):
                    future.result()
                    self.processed_clips += 1
                    self.progress_value = (self.processed_clips / self.total_clips) * 100

            video.close()
            self.queue.put(("message", "Video splitting completed successfully.\n"))

        except Exception as e:
            self.queue.put(("message", f"An error occurred: {e}\n"))
        finally:
            video.close()  # Sicherstellen, dass das Video geschlossen wird
            self.queue.put(("done", None))

    def process_clip(self, clip_info, quality_params, index):
        start_time, end_time, output_path, i = clip_info
        clip = None
        try:
            clip = VideoFileClip(self.input_file).subclip(start_time, end_time)
            logger = CustomLogger(self.queue, index)
            clip.write_videofile(
                output_path,
                audio_codec='aac',
                temp_audiofile=os.path.join(self.output_folder, f"temp_audio_{i}.m4a"),
                remove_temp=True,
                logger=logger,
                **quality_params
            )
        except Exception as e:
            self.queue.put(("message", f"Error processing clip {i+1}: {e}\n"))
        finally:
            if clip:
                clip.close()

class CustomLogger:
    def __init__(self, queue, index):
        self.queue = queue
        self.index = index

    def debug(self, msg):
        self.queue.put(("message", f"Clip {self.index + 1}: {msg}\n"))

    def info(self, msg):
        self.queue.put(("message", f"Clip {self.index + 1}: {msg}\n"))

    def warning(self, msg):
        self.queue.put(("message", f"Clip {self.index + 1}: {msg}\n"))

    def error(self, msg):
        self.queue.put(("message", f"Clip {self.index + 1}: {msg}\n"))

    def __getattr__(self, attr):
        def dummy(*args, **kwargs):
            pass
        return dummy

if __name__ == '__main__':
    root = tk.Tk()
    app = VideoSplitterApp(root)
    root.mainloop()