Merge pull request #13 from ynput/bugfix/OP-8005_thumbnail_duration

Use duration from streams as its more precise
This commit is contained in:
Jakub Ježek 2024-03-06 11:08:03 +01:00 committed by GitHub
commit 09d64758d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -478,7 +478,15 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
# Set video input attributes
max_int = str(2147483647)
video_data = get_ffprobe_data(video_file_path, logger=self.log)
duration = float(video_data["format"]["duration"])
# Use duration of the individual streams since it is returned with
# higher decimal precision than 'format.duration'. We need this
# more precise value for calculating the correct amount of frames
# for higher FPS ranges or decimal ranges, e.g. 29.97 FPS
duration = max(
float(stream.get("duration", 0))
for stream in video_data["streams"]
if stream.get("codec_type") == "video"
)
cmd_args = [
"-y",