Last active
September 22, 2021 11:44
-
-
Save birme/945ba3ed40ccae8638e90cc5b985fee1 to your computer and use it in GitHub Desktop.
Watch-folder upload and transcode with AWS MediaConvert
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 gist shows an example of an ingest application based on Eyevinn Ingest Application Framework [1] plugins | |
// to watch a folder for a new MP4-file and upload and transcode on AWS using AWS MediaConvert. | |
// Copyright 2021 Jonas Birmé | |
// | |
// [1] https://eyevinn.github.io/ingest-application-framework/ | |
const { AwsUploadModule } = require("@eyevinn/iaf-plugin-aws"); | |
const { watch } = require("chokidar"); | |
const { createReadStream } = require("fs"); | |
const WATCH_DIR = process.env.WATCH_DIR; | |
const awsUploadModule = new AwsUploadModule("xnlmxec5a", | |
process.env.AWS_REGION, | |
"lab-testcontent-input", | |
"lab-testcontent-output", | |
"arn:aws:iam::590877988961:role/MediaConvert_Default_Role", | |
"manifest", | |
null, // use a default encoding profile | |
{ hls: "manifest.m3u8" }); | |
awsUploadModule.fileUploadedDelegate = outputs => { | |
console.log(`Upload and transcoding complete: ${outputs["hls"]}`) | |
}; | |
console.log(`Watching for new files in ${WATCH_DIR}`); | |
const watcher = watch([ WATCH_DIR + "/**/*.mp4" ], { | |
persistent: true, | |
ignoreInitial: true | |
}); | |
watcher.on("add", path => { | |
console.log(`Will upload and transcode '${path}'`) | |
const readStream = createReadStream(path); | |
awsUploadModule.onFileAdd(path, readStream); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment