-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathhandler.js
More file actions
20 lines (16 loc) · 714 Bytes
/
handler.js
File metadata and controls
20 lines (16 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { getFileInformation, download, uploadFolder, deleteObject } from './src/s3'
import { getDestinationBucket, getFfmpegParameters } from './src/env'
import { ffprobe, ffmpeg } from './src/ffmpeg'
import { createReadStream } from 'fs'
export const main = async (event, context, callback) => {
const {eventName, bucket, key} = getFileInformation(event)
console.log(`Received ${eventName} for item in bucket: ${bucket}, key: ${key}`)
try {
const destPath = await download(bucket, key)
await ffprobe(destPath)
const outputPath = await ffmpeg(destPath, 'm3u', getFfmpegParameters())
await uploadFolder(getDestinationBucket(), key, outputPath)
} catch (error) {
callback(error)
}
}