SHARE
    TWEET
    Najeebsk

    VIDEOS-MEREGE.pyw

    Jun 30th, 2024
    895
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    Python 2.30 KB | None | 0 0
    1. import tkinter as tk
    2. from tkinter import filedialog, messagebox
    3. import subprocess
    4. import os
    5. class VideoMergerApp:
    6. def __init__(self, root):
    7. self.root = root
    8. self.root.title("Najeeb Video Merger with FFMPEG")
    9. self.root.geometry("340x160")
    10. self.root.configure(bg="#4a4a4a")
    11. self.video_files = []
    12. self.label = tk.Label(root, text="Select video files to merge:")
    13. self.label.pack(pady=10)
    14. self.select_button = tk.Button(root, text="Select Files", command=self.select_files)
    15. self.select_button.pack(pady=5)
    16. self.merge_button = tk.Button(root, text="Merge Videos", command=self.merge_videos, state=tk.DISABLED)
    17. self.merge_button.pack(pady=5)
    18. self.status_label = tk.Label(root, text="")
    19. self.status_label.pack(pady=10)
    20. def select_files(self):
    21. self.video_files = filedialog.askopenfilenames(title="Select Video Files", filetypes=[("Video Files", "*.mp4 *.mkv *.avi")])
    22. if self.video_files:
    23. self.status_label.config(text=f"{len(self.video_files)} files selected.")
    24. self.merge_button.config(state=tk.NORMAL)
    25. else:
    26. self.status_label.config(text="No files selected.")
    27. self.merge_button.config(state=tk.DISABLED)
    28. def merge_videos(self):
    29. output_file = filedialog.asksaveasfilename(defaultextension=".mp4", filetypes=[("MP4 files", "*.mp4")])
    30. if not output_file:
    31. return
    32. temp_file = "temp_list.txt"
    33. with open(temp_file, "w") as f:
    34. for file in self.video_files:
    35. f.write(f"file '{file}'\n")
    36. ffmpeg_command = f"ffmpeg -f concat -safe 0 -i {temp_file} -c copy {output_file}"
    37. try:
    38. subprocess.run(ffmpeg_command, check=True, shell=True)
    39. self.status_label.config(text=f"Videos merged successfully into {output_file}")
    40. except subprocess.CalledProcessError:
    41. self.status_label.config(text="Error occurred while merging videos.")
    42. finally:
    43. os.remove(temp_file)
    44. self.merge_button.config(state=tk.DISABLED)
    45. if __name__ == "__main__":
    46. root = tk.Tk()
    47. app = VideoMergerApp(root)
    48. root.mainloop()
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /