-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncodeFileWithBuiltInPresets.cs
More file actions
72 lines (58 loc) · 2.95 KB
/
EncodeFileWithBuiltInPresets.cs
File metadata and controls
72 lines (58 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
namespace ProcessMyMedia.Samples
{
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
using WorkflowCore.Interface;
using WorkflowCore.Models;
using ProcessMyMedia.Model;
public class EncodeFileWithBuiltInPresets : WofkflowSampleBase<EncodeFileWithBuiltInPresets.EncodeFileWithBuiltInPresetsWorkflow, EncodeFileWithBuiltInPresets.EncodeFileWithBuiltInPresetsWorkflowData>
{
public EncodeFileWithBuiltInPresets(IConfigurationRoot configuration) : base(configuration)
{
}
protected override EncodeFileWithBuiltInPresetsWorkflowData WorflowDatas => new EncodeFileWithBuiltInPresetsWorkflowData()
{
Presets =
{
Model.BuiltInPreset.H264SingleBitrateSD.ToString(),
Model.BuiltInPreset.AdaptiveStreaming.ToString()
},
FilePath = Path.Combine(Directory.GetCurrentDirectory(), @"Assets\Asset2\ignite.mp4"),
DirectoryToDownload = Path.Combine(Directory.GetCurrentDirectory(), "output/", Guid.NewGuid().ToString())
};
public class EncodeFileWithBuiltInPresetsWorkflow : IWorkflow<EncodeFileWithBuiltInPresetsWorkflowData>
{
public string Id => SampleBase.WORKFLOW_NAME;
public int Version => 1;
public void Build(IWorkflowBuilder<EncodeFileWithBuiltInPresetsWorkflowData> builder)
{
builder
.UseDefaultErrorBehavior(WorkflowErrorHandling.Terminate)
.StartWith<Tasks.EncodeFileBuiltInPresetsTask>()
.Input(task => task.FilePath, data => data.FilePath)
.Input(task => task.Presets, data => data.Presets)
.Output(data => data.Outputs, task => task.Output.Job.Outputs)
.ForEach(data => data.Outputs)
.Do(iteration => iteration
.StartWith<Tasks.DownloadAssetTask>()
.Input(task => task.AssetName, (data, context) => ((JobOutputEntity)context.Item).Name)
.Input(task => task.DirectoryToDownload, (data, context) => Path.Combine(data.DirectoryToDownload, ((JobOutputEntity)context.Item).Label))
.Then<Tasks.DeleteAssetTask>()
.Input(task => task.AssetName, (data, context) => ((JobOutputEntity)context.Item).Name));
}
}
public class EncodeFileWithBuiltInPresetsWorkflowData
{
public EncodeFileWithBuiltInPresetsWorkflowData()
{
this.Presets = new List<string>();
}
public string FilePath { get; set; }
public List<string> Presets { get; set; }
public string DirectoryToDownload { get; set; }
public List<JobOutputEntity> Outputs { get; set; }
}
}
}