mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 08:48:13 +00:00
* Fix file_list and convert save_first_frame to use FFMPEG directly * All thumbnail generation now uses FFMPEG engine
20 lines
1.1 KiB
Python
20 lines
1.1 KiB
Python
import subprocess
|
|
from lib.engines.ffmpeg_engine import FFMPEG
|
|
|
|
|
|
def image_sequence_to_video(source_glob_pattern, output_path, framerate=24, encoder="libx264", pix_fmt="yuv420p"):
|
|
subprocess.run([FFMPEG.renderer_path(), "-framerate", str(framerate), "-i", f"{source_glob_pattern}",
|
|
"-c:v", encoder, "-pix_fmt", pix_fmt, output_path], stdout=subprocess.DEVNULL,
|
|
stderr=subprocess.DEVNULL, check=True)
|
|
|
|
|
|
def save_first_frame(source_path, dest_path, max_width=1280):
|
|
subprocess.run([FFMPEG.renderer_path(), '-i', source_path, '-vf', f'scale={max_width}:-1',
|
|
'-vframes', '1', dest_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
|
|
|
|
|
|
def generate_thumbnail(source_path, dest_path, max_width=240, fps=12):
|
|
subprocess.run([FFMPEG.renderer_path(), '-i', source_path, '-vf',
|
|
f"scale={max_width}:trunc(ow/a/2)*2,format=yuv420p", '-r', str(fps), '-c:v', 'libx264', '-preset',
|
|
'ultrafast', '-an', dest_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
|