Skip to content

Commit feeefbd

Browse files
committed
v0.3.1
1 parent d3a4610 commit feeefbd

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎sharp_frames/processing/frame_extractor.py‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ def _run_ffmpeg_extraction(self, video_path: str, output_dir: str, fps: int,
310310
# Build video filters
311311
vf_filters = [f"fps={fps}"]
312312
if width > 0:
313-
vf_filters.append(f"scale={width}:-1")
313+
# Use lanczos scaling for high-quality downsampling
314+
vf_filters.append(f"scale={width}:-1:flags=lanczos")
314315

315316
vf_string = ",".join(vf_filters)
316317

@@ -319,11 +320,20 @@ def _run_ffmpeg_extraction(self, video_path: str, output_dir: str, fps: int,
319320

320321
# Build FFmpeg command - normalize paths for Windows
321322
cmd = [
322-
ffmpeg_executable, '-i', os.path.normpath(video_path),
323+
ffmpeg_executable,
324+
'-hwaccel', 'auto', # Auto-detect and use available hardware acceleration
325+
'-i', os.path.normpath(video_path),
323326
'-vf', vf_string,
327+
]
328+
329+
# Add quality settings for JPEG output
330+
if output_format.lower() in ['jpg', 'jpeg']:
331+
cmd.extend(['-q:v', '1']) # Highest JPEG quality (1-31, lower is better)
332+
333+
cmd.extend([
324334
'-y', # Overwrite output files
325335
os.path.normpath(output_pattern)
326-
]
336+
])
327337

328338
try:
329339
# Estimate total frames if duration is available

0 commit comments

Comments
 (0)