From f0be8cd87704fb82ff946b50dde8418a88a95f5d Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 12 May 2025 13:56:43 +0200 Subject: [PATCH] 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. --- .../plugins/publish/extract_thumbnail.py | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 3626c5f381..9f58be7d94 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -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)