Applied suggestions from @iLLiCiTiT

Simplifies the ffmpeg command construction by moving the seek position argument to the beginning of the command list if a seek position is specified, leading to a clearer and more maintainable structure. This also ensures that the output path is always the last argument passed to ffmpeg.
This commit is contained in:
Jakub Jezek 2025-05-12 13:56:43 +02:00
parent 57b808e924
commit f0be8cd877
No known key found for this signature in database
GPG key ID: 06DBD609ADF27FD9

View file

@ -503,20 +503,19 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
seek_position = duration * self.duration_split
# Build command args
cmd_args = [
"-y",
cmd_args = []
if seek_position > 0.0:
cmd_args.extend(["--ss", str(seek_position)])
# Add generic ffmpeg commands
cmd_args.extend([
"-i", video_file_path,
"-analyzeduration", max_int,
"-probesize", max_int,
]
# Only add -ss if we're seeking to a specific position
if seek_position > 0:
cmd_args.insert(1, "-ss")
cmd_args.insert(2, str(seek_position))
# Ensure we extract exactly one frame
cmd_args.extend(["-frames:v", "1"])
"-y",
"-frames:v", "1",
output_thumb_file_path
])
# add output file path
cmd_args.append(output_thumb_file_path)