Skip to content

Commit 9ef39be

Browse files
committed
Update ai-server cs examples.
1 parent 9f274df commit 9ef39be

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
```csharp
2+
var request = new QueueTrimVideo
3+
{
4+
StartTime = "00:05",
5+
EndTime = "00:10"
6+
};
7+
8+
var response = client.PostFilesWithRequest<QueueMediaTransformResponse>(
9+
request,
10+
[new UploadFile("test_video.mp4", File.OpenRead("files/test_video.mp4"), "video")]
11+
);
12+
13+
var status = await client.GetAsync(new GetJobStatus { RefId = response.RefId });
14+
while (status.JobState is BackgroundJobState.Started or BackgroundJobState.Queued)
15+
{
16+
await Task.Delay(1000);
17+
status = await client.GetAsync(new GetJobStatus { RefId = response.RefId });
18+
}
19+
20+
// Download the trimmed video
21+
var videoUrl = status.Outputs[0].Url;
22+
videoUrl.DownloadFileTo($"trimmed-video-{status.RefId}.mp4");
23+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```csharp
2+
var request = new TrimVideo
3+
{
4+
StartTime = "00:05",
5+
EndTime = "00:10"
6+
};
7+
8+
var response = client.PostFilesWithRequest<MediaTransformResponse>(
9+
request,
10+
[new UploadFile("test_video.mp4", File.OpenRead("files/test_video.mp4"), "video")]
11+
);
12+
13+
var videoUrl = response.Outputs[0].Url;
14+
videoUrl.DownloadFileTo(outputFileName);
15+
```

0 commit comments

Comments
 (0)