-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2addf2b
commit 061277a
Showing
4 changed files
with
81 additions
and
70 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/*jshint loopfunc: true */ | ||
console.log('alpr video'); | ||
|
||
var AWSXRay = require('aws-xray-sdk'); | ||
var AWS = AWSXRay.captureAWS(require('aws-sdk')); | ||
var dynamodb = new AWS.DynamoDB.DocumentClient(); | ||
const s3 = new AWS.S3({ | ||
apiVersion: '2006-03-01', | ||
useAccelerateEndpoint: true | ||
}); | ||
var batch = new AWS.Batch(); | ||
|
||
exports.handler = function(event, context) { | ||
"use strict"; | ||
|
||
for(var i = 0; i < event.Records.length; i++) { | ||
|
||
let record = event.Records[i]; | ||
|
||
let videoId = record.Sns.Message; | ||
|
||
dynamodb.get({ | ||
TableName: "Videos", | ||
Key:{ | ||
"Id": videoId | ||
}, | ||
AttributesToGet: [ | ||
'Files', | ||
] | ||
}, function(err, data) { | ||
if (err) { | ||
console.log(err); | ||
return context.fail(err); | ||
} | ||
else { | ||
let key = data.Item.Files.Original.Key; | ||
|
||
console.log('Getting video url from Bucket [' + data.Item.Files.Original.Bucket + '] Key [' + data.Item.Files.Original.Key + ']'); | ||
var input_file = s3.getSignedUrl('getObject', { | ||
Bucket: data.Item.Files.Original.Bucket, | ||
Key: data.Item.Files.Original.Key, | ||
Expires: 3600 | ||
}); | ||
|
||
var params = { | ||
jobDefinition: process.env.jobDefinition, /* required */ | ||
jobName: process.env.jobName, /* required */ | ||
jobQueue: process.env.jobQueue, /* required */ | ||
containerOverrides: { | ||
environment: [ | ||
{ | ||
name: 'INPUT_FILE', | ||
value: input_file | ||
}, | ||
{ | ||
name: 'VIDEO_ID', | ||
value: videoId | ||
} | ||
] | ||
} | ||
}; | ||
|
||
batch.submitJob(params, function(err, data) { | ||
if (err) { | ||
console.error(err, err.stack); | ||
context.fail(); | ||
return; | ||
} | ||
else { | ||
console.log(data); | ||
context.succeed(); | ||
} | ||
}); | ||
|
||
} | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.