@@ -138,7 +138,7 @@ func (p *mcProvider) outputGroupsFrom(job *db.Job) ([]mediaconvert.OutputGroup,
138
138
}
139
139
mcOutputGroup .Outputs = mcOutputs
140
140
141
- destination := destinationPathFrom ( p . cfg . Destination , job . ID )
141
+ destination := p . destinationPathFrom ( job )
142
142
143
143
switch container {
144
144
case mediaconvert .ContainerTypeCmfc :
@@ -171,7 +171,7 @@ func (p *mcProvider) outputGroupsFrom(job *db.Job) ([]mediaconvert.OutputGroup,
171
171
mcOutputGroup .OutputGroupSettings = & mediaconvert.OutputGroupSettings {
172
172
Type : mediaconvert .OutputGroupTypeFileGroupSettings ,
173
173
FileGroupSettings : & mediaconvert.FileGroupSettings {
174
- Destination : aws .String (destination ),
174
+ Destination : aws .String (destination + "m" ),
175
175
},
176
176
}
177
177
default :
@@ -184,8 +184,14 @@ func (p *mcProvider) outputGroupsFrom(job *db.Job) ([]mediaconvert.OutputGroup,
184
184
return mcOutputGroups , nil
185
185
}
186
186
187
- func destinationPathFrom (destBase string , jobID string ) string {
188
- return fmt .Sprintf ("%s/%s/" , strings .TrimRight (destBase , "/" ), jobID )
187
+ func (p * mcProvider ) destinationPathFrom (job * db.Job ) string {
188
+ var basePath string
189
+ if cfgBasePath := job .DestinationBasePath ; cfgBasePath != "" {
190
+ basePath = cfgBasePath
191
+ } else {
192
+ basePath = p .cfg .Destination
193
+ }
194
+ return fmt .Sprintf ("%s/%s/" , strings .TrimRight (basePath , "/" ), job .ID )
189
195
}
190
196
191
197
func (p * mcProvider ) CreatePreset (preset db.Preset ) (string , error ) {
@@ -221,49 +227,117 @@ func (p *mcProvider) JobStatus(job *db.Job) (*provider.JobStatus, error) {
221
227
return & provider.JobStatus {}, errors .Wrap (err , "fetching job info with the mediaconvert API" )
222
228
}
223
229
224
- return p .jobStatusFrom (job .ProviderJobID , job . ID , jobResp .Job ), nil
230
+ return p .jobStatusFrom (job .ProviderJobID , job , jobResp .Job ), nil
225
231
}
226
232
227
- func (p * mcProvider ) jobStatusFrom (providerJobID string , jobID string , job * mediaconvert.Job ) * provider.JobStatus {
233
+ func (p * mcProvider ) jobStatusFrom (providerJobID string , job * db. Job , mcJob * mediaconvert.Job ) * provider.JobStatus {
228
234
status := & provider.JobStatus {
229
235
ProviderJobID : providerJobID ,
230
236
ProviderName : Name ,
231
- Status : providerStatusFrom (job .Status ),
232
- StatusMessage : statusMsgFrom (job ),
237
+ Status : providerStatusFrom (mcJob .Status ),
238
+ StatusMessage : statusMsgFrom (mcJob ),
233
239
Output : provider.JobOutput {
234
- Destination : destinationPathFrom ( p . cfg . Destination , jobID ),
240
+ Destination : p . destinationPathFrom ( job ),
235
241
},
236
242
}
237
243
238
244
if status .Status == provider .StatusFinished {
239
245
status .Progress = 100
240
- } else if p := job .JobPercentComplete ; p != nil {
246
+ } else if p := mcJob .JobPercentComplete ; p != nil {
241
247
status .Progress = float64 (* p )
242
248
}
243
249
244
250
var files []provider.OutputFile
245
- for _ , groupDetails := range job .OutputGroupDetails {
246
- for _ , outputDetails := range groupDetails .OutputDetails {
247
- if outputDetails .VideoDetails == nil {
251
+ if settings := mcJob .Settings ; settings != nil {
252
+ for _ , group := range settings .OutputGroups {
253
+ groupDestination , err := outputGroupDestinationFrom (group )
254
+ if err != nil {
248
255
continue
249
256
}
257
+ for _ , output := range group .Outputs {
258
+ file := provider.OutputFile {}
259
+
260
+ if modifier := output .NameModifier ; modifier != nil {
261
+ if extension , err := fileExtensionFromContainer (output .ContainerSettings ); err == nil {
262
+ file .Path = groupDestination + * modifier + extension
263
+ } else {
264
+ continue
265
+ }
266
+ } else {
267
+ continue
268
+ }
269
+
270
+ if video := output .VideoDescription ; video != nil {
271
+ if height := video .Height ; height != nil {
272
+ file .Height = * height
273
+ }
274
+
275
+ if width := video .Width ; width != nil {
276
+ file .Width = * width
277
+ }
278
+ }
279
+
280
+ if container , err := containerIdentifierFrom (output .ContainerSettings ); err == nil {
281
+ file .Container = container
282
+ }
283
+
284
+ files = append (files , file )
285
+ }
286
+ }
287
+ }
250
288
251
- file := provider. OutputFile {}
289
+ status . Output . Files = files
252
290
253
- if height := outputDetails .VideoDetails .HeightInPx ; height != nil {
254
- file .Height = * height
255
- }
291
+ return status
292
+ }
256
293
257
- if width := outputDetails .VideoDetails .WidthInPx ; width != nil {
258
- file .Width = * width
259
- }
294
+ func outputGroupDestinationFrom (group mediaconvert.OutputGroup ) (string , error ) {
295
+ if group .OutputGroupSettings == nil {
296
+ return "" , errors .New ("output group contained no settings" )
297
+ }
298
+
299
+ switch group .OutputGroupSettings .Type {
300
+ case mediaconvert .OutputGroupTypeFileGroupSettings :
301
+ fsSettings := group .OutputGroupSettings .FileGroupSettings
302
+ if fsSettings == nil {
303
+ return "" , errors .New ("file group settings were nil" )
304
+ }
260
305
261
- files = append (files , file )
306
+ if fsSettings .Destination == nil {
307
+ return "" , errors .New ("file group destination was nil" )
262
308
}
309
+
310
+ return * fsSettings .Destination , nil
311
+ default :
312
+ return "" , fmt .Errorf ("output enumeration not supported for output group %q" ,
313
+ group .OutputGroupSettings .Type )
263
314
}
264
- status . Output . Files = files
315
+ }
265
316
266
- return status
317
+ func fileExtensionFromContainer (settings * mediaconvert.ContainerSettings ) (string , error ) {
318
+ if settings == nil {
319
+ return "" , errors .New ("container settings were nil" )
320
+ }
321
+
322
+ switch settings .Container {
323
+ case mediaconvert .ContainerTypeMp4 :
324
+ return ".mp4" , nil
325
+ default :
326
+ return "" , fmt .Errorf ("could not determine extension from output container %q" , settings .Container )
327
+ }
328
+ }
329
+
330
+ func containerIdentifierFrom (settings * mediaconvert.ContainerSettings ) (string , error ) {
331
+ if settings == nil {
332
+ return "" , errors .New ("container settings were nil" )
333
+ }
334
+
335
+ switch settings .Container {
336
+ case mediaconvert .ContainerTypeMp4 :
337
+ return "mp4" , nil
338
+ default :
339
+ return "" , fmt .Errorf ("could not determine container identifier from output container %q" , settings .Container )
340
+ }
267
341
}
268
342
269
343
func statusMsgFrom (job * mediaconvert.Job ) string {
0 commit comments