2 Commits

Author SHA1 Message Date
jamie e4f5ce70b8 Merge pull request 'refactor: streamline ffmpeg command construction in VideoEncoder' (#5) from v1.0.2 into master
Reviewed-on: #5
2026-01-08 20:47:49 +00:00
jamie 8ee7f9fefe refactor: streamline ffmpeg command construction in VideoEncoder
Release / release (pull_request) Successful in 1m14s
2026-01-08 20:46:57 +00:00
+5 -4
View File
@@ -389,8 +389,7 @@ class VideoEncoder:
return False, "Invalid video resolution information" return False, "Invalid video resolution information"
cmd = [ cmd = [
'ffmpeg', '-i', input_path, '-c:v', 'libx265', '-c:a', 'copy', 'ffmpeg', '-i', input_path
'-preset', 'medium', '-crf', '28', '-f', 'matroska'
] ]
# Add scaling filter if target resolution is specified # Add scaling filter if target resolution is specified
@@ -404,8 +403,10 @@ class VideoEncoder:
# Ensure width is divisible by 2 (required by video codecs) # Ensure width is divisible by 2 (required by video codecs)
if scale_width % 2 != 0: if scale_width % 2 != 0:
scale_width -= 1 scale_width -= 1
cmd.insert(2, f'scale={scale_width}:{target_height}') cmd.extend(['-vf', f'scale={scale_width}:{target_height}'])
cmd.insert(2, '-vf')
cmd.extend(['-c:v', 'libx265', '-c:a', 'copy',
'-preset', 'medium', '-crf', '28', '-f', 'matroska'])
# Insert user flags if provided # Insert user flags if provided
if ffmpeg_flags: if ffmpeg_flags: