视频截断程序,并将画质提高到1920*1080,声音增加10db


复制代码
import subprocess
import os
import tkinter as tk
from tkinter import ttk, messagebox, filedialog
from ttkthemes import ThemedStyle

# Default video information
default_video_info = [
    ("video1", "00:00:30", "00:01:00"),
    ("video2", "00:01:30", "00:02:00"),
    ("video3", "00:03:30", "00:05:00")
    # Add more video info tuples as needed
]

def generate_videos():
    input_file = input_file_entry.get()
    video_info_text = video_info_textarea.get("1.0", "end-1c")
    output_folder = "output_videos"

    os.makedirs(output_folder, exist_ok=True)

    video_info_lines = video_info_text.split("\n")
    video_info = [tuple(line.split()) for line in video_info_lines if len(line.split()) >= 3]

    for video_name, start_time, end_time in video_info:
        output_file = os.path.join(output_folder, f"{video_name}.mp4")

        # Remove existing file if it exists
        if os.path.exists(output_file):
            os.remove(output_file)

        cmd = [
            "ffmpeg", "-i", input_file, "-ss", start_time, "-to", end_time,
            "-vf", "scale=1920:1080", "-b:v", "2048k", "-c:v", "libx264",
            "-c:a", "aac", "-b:a", "192k", "-af", "volume=10dB",
            output_file
        ]

        subprocess.run(cmd)

    messagebox.showinfo("Completed", "Video splitting, audio volume adjustment, and quality settings completed.")

def select_input_file():
    global input_file
    input_file = filedialog.askopenfilename(filetypes=[("Video files", "*.mp4")])
    input_file_entry.delete(0, tk.END)
    input_file_entry.insert(0, input_file)

root = tk.Tk()
root.title("Video Generation Tool")

# Apply ttkthemes style
style = ThemedStyle(root)
style.set_theme("equilux")  # Set your preferred theme

# Customize background color
style.configure("TFrame", background="#e0e0e0")  # Change to your preferred color

# Calculate screen center
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x = (screen_width - 600) // 2  # Adjust window width as needed
y = (screen_height - 400) // 2  # Adjust window height as needed
root.geometry(f"600x400+{x}+{y}")

input_file_label = ttk.Label(root, text="Input File:")
input_file_label.pack(fill=tk.BOTH, padx=10, pady=(10, 0))

input_file_entry = ttk.Entry(root)
input_file_entry.pack(fill=tk.BOTH, expand=True, padx=10, pady=(0, 10))

select_button = ttk.Button(root, text="Select", command=select_input_file)
select_button.pack(fill=tk.BOTH, padx=10)

video_info_label = ttk.Label(root, text="Video Info:")
video_info_label.pack(fill=tk.BOTH, padx=10, pady=(10, 0))

video_info_textarea = tk.Text(root, height=10, width=40)
video_info_textarea.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)

# Set default video_info values
default_video_info_text = "\n".join([" ".join(info) for info in default_video_info])
video_info_textarea.insert("1.0", default_video_info_text)

generate_button = ttk.Button(root, text="Generate Videos", command=generate_videos)
generate_button.pack(fill=tk.BOTH, padx=10, pady=(0, 10))

root.mainloop()
相关推荐
天上路人2 小时前
采用AI神经网络降噪算法的语言降噪消回音处理芯片NR2049-P
深度学习·神经网络·算法·硬件架构·音视频·实时音视频·可用性测试
清月电子4 小时前
KT148A语音芯片发码很难播放_将4脚对地一下再发正常,什么原因?
单片机·嵌入式硬件·物联网·音视频
科技小E12 小时前
WebRTC实时音视频通话技术EasyRTC嵌入式音视频通信SDK,助力智慧物流打造实时高效的物流管理体系
人工智能·音视频
Icoolkj16 小时前
可灵 AI:开启 AI 视频创作新时代
人工智能·音视频
SuperW1 天前
视频编码原理讲解一:VCL层和NAL层的讲解
音视频
Panesle1 天前
HunyuanCustom:文生视频框架论文速读
人工智能·算法·音视频·文生视频
程序员JerrySUN2 天前
驱动开发硬核特训 · Day 30(下篇): 深入解析 lm48100q I2C 音频编解码器驱动模型(基于 i.MX8MP)
linux·驱动开发·架构·音视频
读心悦2 天前
5000字总结 HTML5 中的音频和视频,关羽标签、属性、API 和最佳实践
前端·音视频·html5
东风西巷2 天前
BLURRR剪辑软件免费版:创意剪辑,轻松上手,打造个性视频
android·智能手机·音视频·生活·软件需求
weixin_446260852 天前
视觉革命来袭!ComfyUI-LTXVideo 让视频创作更高效
人工智能·音视频