#!/usr/bin/env python3
import subprocess
import os

# 创建concat文件
list_file = 'concat_list.txt'
with open(list_file, 'w', encoding='utf-8') as f:
    f.write("file 'segment_01.mp4'\n")
    f.write("file 'C:/Users/ad/AppData/Local/Temp/paused_segment.mp4'\n")

# 执行拼接
args = [
    'ffmpeg',
    '-y',
    '-f', 'concat',
    '-safe', '0',
    '-i', list_file,
    '-c:v', 'libx264',
    '-c:a', 'aac',
    '-ar', '44100',
    '-ac', '1',
    '-pix_fmt', 'yuv420p',
    'segment_01_extended2.mp4'
]

try:
    result = subprocess.run(args, check=True, capture_output=True, text=True)
    print("拼接成功!")
    os.remove(list_file)
except subprocess.CalledProcessError as e:
    print(f"拼接失败: {e}")
    print(f"错误输出: {e.stderr}")
