1
+ {
2
+ "$connections" : {
3
+ "value" : {
4
+ "aci" : {
5
+ "connectionId" : " /subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/aci" ,
6
+ "connectionName" : " aci" ,
7
+ "id" : " /subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/aci"
8
+ },
9
+ "azurefile" : {
10
+ "connectionId" : " /subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/azurefile" ,
11
+ "connectionName" : " azurefile" ,
12
+ "id" : " /subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/azurefile"
13
+ },
14
+ "outlook" : {
15
+ "connectionId" : " /subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/outlook" ,
16
+ "connectionName" : " outlook" ,
17
+ "id" : " /subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/outlook"
18
+ },
19
+ "videoindexer-v2" : {
20
+ "connectionId" : " /subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/connections/videoindexer-v2" ,
21
+ "connectionName" : " videoindexer-v2" ,
22
+ "id" : " /subscriptions/<sub-id>/providers/Microsoft.Web/locations/westus2/managedApis/videoindexer-v2"
23
+ }
24
+ }
25
+ },
26
+ "definition" : {
27
+ "$schema" : " https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#" ,
28
+ "actions" : {
29
+ "Create_container_group_2" : {
30
+ "inputs" : {
31
+ "body" : {
32
+ "location" : " westus2" ,
33
+ "properties" : {
34
+ "containers" : [
35
+ {
36
+ "name" : " concat-ffmpeg" ,
37
+ "properties" : {
38
+ "command" : [
39
+ " /opt/ffmpeg/bin/ffmpeg" ,
40
+ " -f" ,
41
+ " concat" ,
42
+ " -safe" ,
43
+ " 0" ,
44
+ " -i" ,
45
+ " /aci/insights/@{body('Create_file_2')?['Name']}" ,
46
+ " -c" ,
47
+ " copy" ,
48
+ " -y" ,
49
+ " /aci/output/@{body('Get_Video_Index')?['name']}-output.mkv"
50
+ ],
51
+ "image" : " offbytwo/ffmpeg" ,
52
+ "resources" : {
53
+ "requests" : {
54
+ "cpu" : 2 ,
55
+ "memoryInGB" : 1.5
56
+ }
57
+ },
58
+ "volumeMounts" : [
59
+ {
60
+ "mountPath" : " /aci/insights/" ,
61
+ "name" : " insights" ,
62
+ "readOnly" : true
63
+ },
64
+ {
65
+ "mountPath" : " /aci/shots/" ,
66
+ "name" : " shots" ,
67
+ "readOnly" : true
68
+ },
69
+ {
70
+ "mountPath" : " /aci/output/" ,
71
+ "name" : " output" ,
72
+ "readOnly" : false
73
+ }
74
+ ]
75
+ }
76
+ }
77
+ ],
78
+ "osType" : " Linux" ,
79
+ "restartPolicy" : " Never" ,
80
+ "volumes" : [
81
+ {
82
+ "azureFile" : {
83
+ "readOnly" : true ,
84
+ "shareName" : " shots" ,
85
+ "storageAccountKey" : " " ,
86
+ "storageAccountName" : " serverlessencodermedia"
87
+ },
88
+ "name" : " shots"
89
+ },
90
+ {
91
+ "azureFile" : {
92
+ "readOnly" : true ,
93
+ "shareName" : " insights" ,
94
+ "storageAccountKey" : " " ,
95
+ "storageAccountName" : " serverlessencodermedia"
96
+ },
97
+ "name" : " insights"
98
+ },
99
+ {
100
+ "azureFile" : {
101
+ "readOnly" : false ,
102
+ "shareName" : " output" ,
103
+ "storageAccountKey" : " " ,
104
+ "storageAccountName" : " serverlessencodermedia"
105
+ },
106
+ "name" : " output"
107
+ }
108
+ ]
109
+ }
110
+ },
111
+ "host" : {
112
+ "connection" : {
113
+ "name" : " @parameters('$connections')['aci']['connectionId']"
114
+ }
115
+ },
116
+ "method" : " put" ,
117
+ "path" : " /subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('serverless-encoder-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent('concat-ffmpeg')}" ,
118
+ "queries" : {
119
+ "x-ms-api-version" : " 2017-10-01-preview"
120
+ }
121
+ },
122
+ "runAfter" : {
123
+ "Create_file_2" : [
124
+ " Succeeded"
125
+ ]
126
+ },
127
+ "type" : " ApiConnection"
128
+ },
129
+ "Create_file" : {
130
+ "inputs" : {
131
+ "body" : " @body('Get_Video_Index')?['videos'][0]['insights']['shots']" ,
132
+ "host" : {
133
+ "connection" : {
134
+ "name" : " @parameters('$connections')['azurefile']['connectionId']"
135
+ }
136
+ },
137
+ "method" : " post" ,
138
+ "path" : " /datasets/default/files" ,
139
+ "queries" : {
140
+ "folderPath" : " /insights" ,
141
+ "name" : " @{concat(body('Get_Video_Index')?['name'], '-insights','.json')}" ,
142
+ "queryParametersSingleEncoded" : true
143
+ }
144
+ },
145
+ "runAfter" : {
146
+ "Get_Video_Index" : [
147
+ " Succeeded"
148
+ ]
149
+ },
150
+ "runtimeConfiguration" : {
151
+ "contentTransfer" : {
152
+ "transferMode" : " Chunked"
153
+ }
154
+ },
155
+ "type" : " ApiConnection"
156
+ },
157
+ "Create_file_2" : {
158
+ "inputs" : {
159
+ "body" : " @body('ffmpeg-concat')" ,
160
+ "host" : {
161
+ "connection" : {
162
+ "name" : " @parameters('$connections')['azurefile']['connectionId']"
163
+ }
164
+ },
165
+ "method" : " post" ,
166
+ "path" : " /datasets/default/files" ,
167
+ "queries" : {
168
+ "folderPath" : " /insights" ,
169
+ "name" : " @{concat(body('Get_Video_Index')?['name'],'-concat','.txt')}" ,
170
+ "queryParametersSingleEncoded" : true
171
+ }
172
+ },
173
+ "runAfter" : {
174
+ "ffmpeg-concat" : [
175
+ " Succeeded"
176
+ ]
177
+ },
178
+ "runtimeConfiguration" : {
179
+ "contentTransfer" : {
180
+ "transferMode" : " Chunked"
181
+ }
182
+ },
183
+ "type" : " ApiConnection"
184
+ },
185
+ "For_each" : {
186
+ "actions" : {
187
+ "Create_container_group" : {
188
+ "inputs" : {
189
+ "body" : {
190
+ "location" : " westus2" ,
191
+ "properties" : {
192
+ "containers" : [
193
+ " @items('For_each')"
194
+ ],
195
+ "osType" : " Linux" ,
196
+ "restartPolicy" : " Never" ,
197
+ "volumes" : [
198
+ {
199
+ "azureFile" : {
200
+ "readOnly" : false ,
201
+ "shareName" : " source" ,
202
+ "storageAccountKey" : " " ,
203
+ "storageAccountName" : " serverlessncodermedia"
204
+ },
205
+ "name" : " source"
206
+ },
207
+ {
208
+ "azureFile" : {
209
+ "readOnly" : false ,
210
+ "shareName" : " shots" ,
211
+ "storageAccountKey" : " " ,
212
+ "storageAccountName" : " serverlessncodermedia"
213
+ },
214
+ "name" : " shots"
215
+ }
216
+ ]
217
+ }
218
+ },
219
+ "host" : {
220
+ "connection" : {
221
+ "name" : " @parameters('$connections')['aci']['connectionId']"
222
+ }
223
+ },
224
+ "method" : " put" ,
225
+ "path" : " /subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(items('For_each')?[0]['name'])}" ,
226
+ "queries" : {
227
+ "x-ms-api-version" : " 2017-10-01-preview"
228
+ }
229
+ },
230
+ "runAfter" : {},
231
+ "type" : " ApiConnection"
232
+ },
233
+ "Delete_container_group" : {
234
+ "inputs" : {
235
+ "host" : {
236
+ "connection" : {
237
+ "name" : " @parameters('$connections')['aci']['connectionId']"
238
+ }
239
+ },
240
+ "method" : " delete" ,
241
+ "path" : " /subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(items('For_each')?[0]['name'])}" ,
242
+ "queries" : {
243
+ "x-ms-api-version" : " 2017-10-01-preview"
244
+ }
245
+ },
246
+ "runAfter" : {
247
+ "Until_2" : [
248
+ " Succeeded"
249
+ ]
250
+ },
251
+ "type" : " ApiConnection"
252
+ },
253
+ "Until" : {
254
+ "actions" : {
255
+ "Delay" : {
256
+ "inputs" : {
257
+ "interval" : {
258
+ "count" : 1 ,
259
+ "unit" : " Minute"
260
+ }
261
+ },
262
+ "runAfter" : {},
263
+ "type" : " Wait"
264
+ },
265
+ "Get_properties_of_a_container_group" : {
266
+ "inputs" : {
267
+ "host" : {
268
+ "connection" : {
269
+ "name" : " @parameters('$connections')['aci']['connectionId']"
270
+ }
271
+ },
272
+ "method" : " get" ,
273
+ "path" : " /subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(items('For_each')?[0]['name'])}" ,
274
+ "queries" : {
275
+ "x-ms-api-version" : " 2017-10-01-preview"
276
+ }
277
+ },
278
+ "runAfter" : {
279
+ "Delay" : [
280
+ " Succeeded"
281
+ ]
282
+ },
283
+ "type" : " ApiConnection"
284
+ }
285
+ },
286
+ "expression" : " @equals(body('Get_properties_of_a_container_group')?['properties']?['provisioningState'], 'Succeeded')" ,
287
+ "limit" : {
288
+ "count" : 60 ,
289
+ "timeout" : " PT1H"
290
+ },
291
+ "runAfter" : {
292
+ "Create_container_group" : [
293
+ " Succeeded"
294
+ ]
295
+ },
296
+ "type" : " Until"
297
+ },
298
+ "Until_2" : {
299
+ "actions" : {
300
+ "Delay_2" : {
301
+ "inputs" : {
302
+ "interval" : {
303
+ "count" : 2 ,
304
+ "unit" : " Minute"
305
+ }
306
+ },
307
+ "runAfter" : {},
308
+ "type" : " Wait"
309
+ },
310
+ "Get_properties_of_a_container_group_2" : {
311
+ "inputs" : {
312
+ "host" : {
313
+ "connection" : {
314
+ "name" : " @parameters('$connections')['aci']['connectionId']"
315
+ }
316
+ },
317
+ "method" : " get" ,
318
+ "path" : " /subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('encoding-containers-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(items('For_each')?[0]['name'])}" ,
319
+ "queries" : {
320
+ "x-ms-api-version" : " 2017-10-01-preview"
321
+ }
322
+ },
323
+ "runAfter" : {
324
+ "Delay_2" : [
325
+ " Succeeded"
326
+ ]
327
+ },
328
+ "type" : " ApiConnection"
329
+ }
330
+ },
331
+ "expression" : " @equals(body('Get_properties_of_a_container_group_2')?['properties']?['instanceView']?['state'], '')" ,
332
+ "limit" : {
333
+ "count" : 60 ,
334
+ "timeout" : " PT1H"
335
+ },
336
+ "runAfter" : {
337
+ "Until" : [
338
+ " Succeeded"
339
+ ]
340
+ },
341
+ "type" : " Until"
342
+ }
343
+ },
344
+ "foreach" : " @json(body('parse-shots'))" ,
345
+ "runAfter" : {
346
+ "parse-shots" : [
347
+ " Succeeded"
348
+ ]
349
+ },
350
+ "runtimeConfiguration" : {
351
+ "concurrency" : {
352
+ "repetitions" : 50
353
+ }
354
+ },
355
+ "type" : " Foreach"
356
+ },
357
+ "Get_Account_Access_Token" : {
358
+ "inputs" : {
359
+ "host" : {
360
+ "connection" : {
361
+ "name" : " @parameters('$connections')['videoindexer-v2']['connectionId']"
362
+ }
363
+ },
364
+ "method" : " get" ,
365
+ "path" : " /auth/@{encodeURIComponent('westus2')}/Accounts/@{encodeURIComponent('<access-token>')}/AccessToken" ,
366
+ "queries" : {
367
+ "allowEdit" : false
368
+ }
369
+ },
370
+ "runAfter" : {},
371
+ "type" : " ApiConnection"
372
+ },
373
+ "Get_Video_Index" : {
374
+ "inputs" : {
375
+ "host" : {
376
+ "connection" : {
377
+ "name" : " @parameters('$connections')['videoindexer-v2']['connectionId']"
378
+ }
379
+ },
380
+ "method" : " get" ,
381
+ "path" : " /@{encodeURIComponent('westus2')}/Accounts/@{encodeURIComponent('<access-token>')}/Videos/@{encodeURIComponent(triggerOutputs()['queries']['id'])}/Index" ,
382
+ "queries" : {
383
+ "accessToken" : " @body('Get_Account_Access_Token')"
384
+ }
385
+ },
386
+ "runAfter" : {
387
+ "Get_Account_Access_Token" : [
388
+ " Succeeded"
389
+ ]
390
+ },
391
+ "type" : " ApiConnection"
392
+ },
393
+ "Send_an_email_(V2)" : {
394
+ "inputs" : {
395
+ "body" : {
396
+ "Body" : " <p>Video file name: /aci/output/@{body('Get_Video_Index')?['name']}-output.mkv</p>" ,
397
+ "Subject" : " Encoded video now available" ,
398
+ "To" : " <email-to-send-completed-notification-to>"
399
+ },
400
+ "host" : {
401
+ "connection" : {
402
+ "name" : " @parameters('$connections')['outlook']['connectionId']"
403
+ }
404
+ },
405
+ "method" : " post" ,
406
+ "path" : " /v2/Mail"
407
+ },
408
+ "runAfter" : {
409
+ "Until_3" : [
410
+ " Succeeded"
411
+ ]
412
+ },
413
+ "type" : " ApiConnection"
414
+ },
415
+ "Until_3" : {
416
+ "actions" : {
417
+ "Delay_3" : {
418
+ "inputs" : {
419
+ "interval" : {
420
+ "count" : 1 ,
421
+ "unit" : " Minute"
422
+ }
423
+ },
424
+ "runAfter" : {},
425
+ "type" : " Wait"
426
+ },
427
+ "Get_properties_of_a_container_group_3" : {
428
+ "inputs" : {
429
+ "host" : {
430
+ "connection" : {
431
+ "name" : " @parameters('$connections')['aci']['connectionId']"
432
+ }
433
+ },
434
+ "method" : " get" ,
435
+ "path" : " /subscriptions/@{encodeURIComponent('<sub-id>')}/resourceGroups/@{encodeURIComponent('serverless-encoder-rg')}/providers/Microsoft.ContainerInstance/containerGroups/@{encodeURIComponent(body('Create_container_group_2')?['name'])}" ,
436
+ "queries" : {
437
+ "x-ms-api-version" : " 2017-10-01-preview"
438
+ }
439
+ },
440
+ "runAfter" : {
441
+ "Delay_3" : [
442
+ " Succeeded"
443
+ ]
444
+ },
445
+ "type" : " ApiConnection"
446
+ }
447
+ },
448
+ "expression" : " @equals(body('Get_properties_of_a_container_group_3')?['properties']?['instanceView']?['state'], '')" ,
449
+ "limit" : {
450
+ "count" : 60 ,
451
+ "timeout" : " PT1H"
452
+ },
453
+ "runAfter" : {
454
+ "Create_container_group_2" : [
455
+ " Succeeded"
456
+ ]
457
+ },
458
+ "type" : " Until"
459
+ },
460
+ "ffmpeg-concat" : {
461
+ "inputs" : {
462
+ "body" : " @body('Get_Video_Index')?['videos'][0]['insights']['shots']" ,
463
+ "function" : {
464
+ "id" : " /subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/sites/serverless-encoder-functions/functions/ffmpeg-concat"
465
+ },
466
+ "headers" : {
467
+ "Content-Type" : " application/json" ,
468
+ "aciShotsVideoPath" : " /aci/shots/"
469
+ }
470
+ },
471
+ "runAfter" : {
472
+ "For_each" : [
473
+ " Succeeded"
474
+ ]
475
+ },
476
+ "type" : " Function"
477
+ },
478
+ "parse-shots" : {
479
+ "inputs" : {
480
+ "body" : " @body('Get_Video_Index')?['videos'][0]['insights']['shots']" ,
481
+ "function" : {
482
+ "id" : " /subscriptions/<sub-id>/resourceGroups/serverless-encoder-rg/providers/Microsoft.Web/sites/serverless-encoder-functions/functions/parse-shots"
483
+ },
484
+ "headers" : {
485
+ "Content-Type" : " application/json" ,
486
+ "aciDestinationVideoMountName" : " shots" ,
487
+ "aciDestinationVideoPath" : " /aci/shots/" ,
488
+ "aciSourceVideoMountName" : " source" ,
489
+ "aciSourceVideoPath" : " /aci/source/" ,
490
+ "dockerImage" : " singhkays/ffmpeg-av1-libaom" ,
491
+ "ffmpegBinaryPath" : " /opt/ffmpeg/bin" ,
492
+ "requestedCPUCores" : " 2" ,
493
+ "requestedMemoryInGB" : " 2" ,
494
+ "videoName" : " @body('Get_Video_Index')?['name']"
495
+ }
496
+ },
497
+ "runAfter" : {
498
+ "Create_file" : [
499
+ " Succeeded"
500
+ ]
501
+ },
502
+ "type" : " Function"
503
+ }
504
+ },
505
+ "contentVersion" : " 1.0.0.0" ,
506
+ "outputs" : {},
507
+ "parameters" : {
508
+ "$connections" : {
509
+ "defaultValue" : {},
510
+ "type" : " Object"
511
+ }
512
+ },
513
+ "triggers" : {
514
+ "manual" : {
515
+ "inputs" : {
516
+ "schema" : {}
517
+ },
518
+ "kind" : " Http" ,
519
+ "type" : " Request"
520
+ }
521
+ }
522
+ }
523
+ }
0 commit comments