-
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
Showing
8 changed files
with
9,613 additions
and
1,254 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 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,41 @@ | ||
const AWS = require('aws-sdk'); | ||
const ffmpeg = require('fluent-ffmpeg'); | ||
const stream = require('stream'); | ||
|
||
module.exports.handler = async (event) => { | ||
|
||
const s3 = new AWS.S3(); | ||
const url = event.streamingUrl; | ||
const referer = event.referer || null; | ||
const inputOptions = referer ? ["-referer", referer] : []; | ||
const bucket = event.destinationBucket; | ||
const key = event.destinationKey; | ||
const pass = new stream.PassThrough(); | ||
|
||
return new Promise((resolve, reject) => { | ||
ffmpeg() | ||
.input(url) | ||
.inputOptions(inputOptions) | ||
.format('mp3') | ||
.output(pass, { end: true }) | ||
.on('start', () => { | ||
s3.upload({ | ||
Bucket: bucket, | ||
Key: key, | ||
Body: pass, | ||
}, (error, _data) => { | ||
if (error) { | ||
console.error('upload failed', error); | ||
reject(error); | ||
} else { | ||
resolve({ success: true }); | ||
} | ||
}); | ||
}) | ||
.on('error', (error) => { | ||
console.error('ffmpeg error', error); | ||
reject(error); | ||
}) | ||
.run(); | ||
}); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 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 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