From c07e4832e7e59983caff86b14457bc5a05187366 Mon Sep 17 00:00:00 2001 From: John Andrews Date: Sat, 15 Feb 2025 13:57:18 +1300 Subject: [PATCH] r --- VideoNodes/VideoNodes/CreateThumbnail.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/VideoNodes/VideoNodes/CreateThumbnail.cs b/VideoNodes/VideoNodes/CreateThumbnail.cs index 134df0ad..7a270196 100644 --- a/VideoNodes/VideoNodes/CreateThumbnail.cs +++ b/VideoNodes/VideoNodes/CreateThumbnail.cs @@ -37,12 +37,24 @@ public class CreateThumbnail : VideoNode [NumberInt(3)] [DefaultValue(200)] public int Height { get; set; } + + [Boolean(4)] + public bool UsePercent { get; set; } /// /// The time in the video to capture the thumbnail (in seconds or percentage of the video duration). /// - [Time(4)] + [Time(5)] + [ConditionEquals(nameof(UsePercent), false)] public TimeSpan Time { get; set; } + + /// + /// The time in the video to capture the thumbnail (in seconds or percentage of the video duration). + /// + [Slider(6)] + [Range(0, 100)] + [ConditionEquals(nameof(UsePercent), true)] + public int Percent { get; set; } /// @@ -108,6 +120,14 @@ public class CreateThumbnail : VideoNode if (string.IsNullOrWhiteSpace(output)) output = FileHelper.ChangeExtension(args.FileName, "jpg"); + if (UsePercent) + { + TimeSpan duration = videoInfo.VideoStreams[0].Duration; + // get time from Percent (0 to 100) of duraiton, time should be seconds + Time = TimeSpan.FromSeconds(duration.TotalSeconds * (Percent / 100.0)); + args.Logger?.ILog($"Percent time: {Time} seconds"); + } + // Ensure time is within bounds TimeSpan captureTime = GetValidCaptureTime(videoInfo.VideoStreams[0].Duration);