视频截断程序,并将画质提高到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()
相关推荐
小鹿研究点东西3 小时前
AI直播工具实操:从直播录制、AI剪辑去重到直播伴侣开播完整流程
人工智能·自动化·音视频·语音识别
wen_zhufeng4 小时前
信号与系统:采样、量化与信号连续/离散答疑文档
音视频
byte轻骑兵5 小时前
【LE Audio】CAS精讲[1]: 基础约定定乾坤,读懂音频协同的通用规则
音视频·蓝牙耳机·蓝牙音箱·le audio·低功耗音频
肖爱Kun6 小时前
STL标准模块库操作
开发语言·音视频
2601_958352906 小时前
双麦 DSP 音频拾音模块 A-68:多场景远场语音交互的声学解决方案
嵌入式硬件·音视频·降噪·回音消除·音频处理模块
2601_958352908 小时前
对讲系统音频优化实战:解决回声、啸叫、环境噪音与远场拾音难题
嵌入式硬件·音视频·语音识别·降噪处理·音频处理模块·硬件开发模块
南山有乔木7898 小时前
下载的ncm歌曲不能播放怎么办?NCM在线转MP3怎么操作?手机电脑转换教程参考
音视频
开开心心就好9 小时前
解决截图被拦截黑屏问题的免费小工具
安全·智能手机·flink·kafka·pdf·音视频·1024程序员节
2601_958352909 小时前
双麦 DSP 音频模块实战:一文梳理 A-68 在全行业场景的声学解决方案与落地要点
前端·嵌入式硬件·音视频·语音识别·降噪消回音·音频处理模块
Deitymoon10 小时前
RV1126——OSD模块和SDL_TTF结合输出H264文件
计算机视觉·音视频·rv1126·osd