Skip to content

Commit 3f0a1c5

Browse files
committed
Alter handling of start/endtime to be simpler and limit to minutes + seconds.
1 parent 999a409 commit 3f0a1c5

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

AiServer.ServiceInterface/Generation/ComfyProvider.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ private ComfyClient GetClient(MediaProvider provider)
9999
// Last check for null seed
100100
request.Seed ??= Random.Shared.Next();
101101
var comfyWorkflowReq = request.ConvertTo<ComfyWorkflowRequest>();
102+
// Ensure task type is set
103+
comfyWorkflowReq.TaskType = request.TaskType switch
104+
{
105+
AiTaskType.TextToImage => ComfyTaskType.TextToImage,
106+
AiTaskType.ImageToImage => ComfyTaskType.ImageToImage,
107+
AiTaskType.ImageUpscale => ComfyTaskType.ImageUpscale,
108+
AiTaskType.ImageWithMask => ComfyTaskType.ImageWithMask,
109+
AiTaskType.ImageToText => ComfyTaskType.ImageToText,
110+
AiTaskType.TextToAudio => ComfyTaskType.TextToAudio,
111+
AiTaskType.TextToSpeech => ComfyTaskType.TextToSpeech,
112+
AiTaskType.SpeechToText => ComfyTaskType.SpeechToText,
113+
_ => throw new ArgumentOutOfRangeException()
114+
};
102115
comfyWorkflowReq =
103116
comfyWorkflowReq.ApplyModelDefaults(AppConfig.Instance, modelSettings.ConvertTo<ComfyApiModelSettings>());
104117
var response = await comfyClient.PromptGenerationAsync(comfyWorkflowReq, token, waitResult: true);

AiServer.ServiceInterface/VideoServices.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ public async Task<object> Any(TrimVideo request)
124124

125125
private void ValidateTimeFormat(string time, string fieldName)
126126
{
127-
if (!Regex.IsMatch(time, @"^\d{2}:\d{2}$"))
127+
if (!Regex.IsMatch(time, @"^(\d{1,3}):([0-5]\d)$"))
128128
{
129-
throw new ArgumentException($"Invalid {fieldName} format. Expected format: mm:ss");
129+
throw new ArgumentException($"Invalid {fieldName} format. Expected format: m:ss, mm:ss, or mmm:ss");
130130
}
131131
}
132132

AiServer.ServiceModel/MediaTransforms.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ public class CropVideo : IMediaTransform, IReturn<MediaTransformResponse>
266266
[ValidateApiKey]
267267
public class TrimVideo : IMediaTransform, IReturn<MediaTransformResponse>
268268
{
269-
[ApiMember(Description = "The start time of the trimmed video (format: HH:MM:SS)")]
270-
[Description("The start time of the trimmed video (format: HH:MM:SS)")]
269+
[ApiMember(Description = "The start time of the trimmed video (format: MM:SS)")]
270+
[Description("The start time of the trimmed video (format: MM:SS)")]
271271
[Required]
272272
public string StartTime { get; set; }
273273

274-
[ApiMember(Description = "The end time of the trimmed video (format: HH:MM:SS)")]
275-
[Description("The end time of the trimmed video (format: HH:MM:SS)")]
274+
[ApiMember(Description = "The end time of the trimmed video (format: MM:SS)")]
275+
[Description("The end time of the trimmed video (format: MM:SS)")]
276276
public string? EndTime { get; set; }
277277

278278
[Required]

0 commit comments

Comments
 (0)