Skip to content

Commit

Permalink
Basically working through download link
Browse files Browse the repository at this point in the history
  • Loading branch information
kdid committed Sep 15, 2023
1 parent 0b10a02 commit 81fa40d
Show file tree
Hide file tree
Showing 15 changed files with 3,502 additions and 1,979 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
nodejs 16.14.0
java corretto-19.0.1.10.1
aws-sam-cli 1.97.0
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const { GetJobCommand, MediaConvertClient } = require("@aws-sdk/client-mediaconv
module.exports.handler = async (event) => {

console.log("TRANSCODE COMPLETE LAMBDA")
console.log("event.jobId", event.jobId)
console.log("event", event)
if(!event.jobId) return {success: false}

const status = await checkJobStatus(event.jobId)

return {status: status}
return {jobId: event.jobId, status: status, destination: event.destination}
};

async function checkJobStatus(jobId){
Expand Down
42 changes: 42 additions & 0 deletions lambda/media-transcode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { CreateJobCommand, MediaConvertClient } = require("@aws-sdk/client-mediaconvert");


module.exports.handler = async (event) => {

console.log("MEDIA CONVERT LAMBDA")
console.log(event)

const jobQueueArn = process.env.MEDIA_CONVERT_JOB_QUEUE_ARN;
const iamRoleArn = process.env.MEDIA_CONVERT_ROLE_ARN;

const params = {
"Queue": jobQueueArn,
"UserMetadata": {},
"Role": iamRoleArn,
"Settings": event.settings,
"AccelerationSettings": {
"Mode": "DISABLED"
},
"StatusUpdateInterval": "SECONDS_60",
"Priority": 0
}

const job = await createJob(params);

return {jobId: job.Job.Id, status: job.Job.Status}
};

async function createJob(params){
const mediaConvertClient = new MediaConvertClient({endpoint: process.env.MEDIA_CONVERT_ENDPOINT});

try {
const data = await mediaConvertClient.send(new CreateJobCommand(params));
console.log("Success! ", data);
return data
} catch (err) {
console.log("Error", err);
return null;
}

}

Loading

0 comments on commit 81fa40d

Please sign in to comment.