Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import filedialog, messagebox
- import subprocess
- import os
- class VideoMergerApp:
- def __init__(self, root):
- self.root = root
- self.root.title("Najeeb Video Merger with FFMPEG")
- self.root.geometry("340x160")
- self.root.configure(bg="#4a4a4a")
- self.video_files = []
- self.label = tk.Label(root, text="Select video files to merge:")
- self.label.pack(pady=10)
- self.select_button = tk.Button(root, text="Select Files", command=self.select_files)
- self.select_button.pack(pady=5)
- self.merge_button = tk.Button(root, text="Merge Videos", command=self.merge_videos, state=tk.DISABLED)
- self.merge_button.pack(pady=5)
- self.status_label = tk.Label(root, text="")
- self.status_label.pack(pady=10)
- def select_files(self):
- self.video_files = filedialog.askopenfilenames(title="Select Video Files", filetypes=[("Video Files", "*.mp4 *.mkv *.avi")])
- if self.video_files:
- self.status_label.config(text=f"{len(self.video_files)} files selected.")
- self.merge_button.config(state=tk.NORMAL)
- else:
- self.status_label.config(text="No files selected.")
- self.merge_button.config(state=tk.DISABLED)
- def merge_videos(self):
- output_file = filedialog.asksaveasfilename(defaultextension=".mp4", filetypes=[("MP4 files", "*.mp4")])
- if not output_file:
- return
- temp_file = "temp_list.txt"
- with open(temp_file, "w") as f:
- for file in self.video_files:
- f.write(f"file '{file}'\n")
- ffmpeg_command = f"ffmpeg -f concat -safe 0 -i {temp_file} -c copy {output_file}"
- try:
- subprocess.run(ffmpeg_command, check=True, shell=True)
- self.status_label.config(text=f"Videos merged successfully into {output_file}")
- except subprocess.CalledProcessError:
- self.status_label.config(text="Error occurred while merging videos.")
- finally:
- os.remove(temp_file)
- self.merge_button.config(state=tk.DISABLED)
- if __name__ == "__main__":
- root = tk.Tk()
- app = VideoMergerApp(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement