import os
import shutil
from PIL import Image
import subprocess
def process_images(target_dir, video_output, fps, sound_file):
if sound_file:
ffmpeg_command = f"ffmpeg -framerate {fps} -i {target_dir}/%07d.png -i {sound_file} -c:a copy -c:v libx264 -pix_fmt yuv420p -map 0:v -map 1:a {video_output}"
else:
ffmpeg_command = f"ffmpeg -framerate {fps} -i {target_dir}/%07d.png -c:v libx264 -pix_fmt yuv420p {video_output}"
subprocess.run(ffmpeg_command, shell=True)
target_dir = './combine'
video_output = 'output_video2.mp4'
fps = 30
sound_file = "sound.mp4"
process_images(target_dir, video_output, fps, sound_file)