aws-transcode
Advanced tools
Comparing version 1.0.0 to 1.1.0-beta.0
{ | ||
"name": "aws-transcode", | ||
"version": "1.0.0", | ||
"version": "1.1.0-beta.0", | ||
"description": "A promise based wrapper to make transcoding with AWS easy.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -17,3 +17,3 @@ # aws-transcode | ||
const transcode = require('aws-transcode'); | ||
const key = 'input/video.mp4'; | ||
const input = 'input/video.mp4'; | ||
const outputs = [ | ||
@@ -38,3 +38,3 @@ { | ||
const res = await transcode(key, outputs, config); | ||
const res = await transcode(input, outputs, config); | ||
@@ -49,2 +49,11 @@ if (res === false) { | ||
### Extracting a part of the input file. | ||
The `input` can also be an object with a `key` (required) and `start`, `duration` values (optional). | ||
```js | ||
const input = { key: 'input/video.mp4', start: 5, duration: 10 }; | ||
const res = await transcode(input, outputs, config); | ||
``` | ||
## License | ||
@@ -51,0 +60,0 @@ |
@@ -29,3 +29,6 @@ const abind = require('abind'); | ||
* | ||
* @param {string} key | ||
* @param {object} input | ||
* {string} key input key | ||
* {number} start optional defaults to 0 | ||
* {number} duration optional defaults to duration of input file | ||
* @param {object[]} outputs an array of outputs { key, presetId, thumbnailPattern } | ||
@@ -39,7 +42,7 @@ * {string} key output key (bucket is defined in the pipeline) | ||
*/ | ||
async transcode (key, outputs) { | ||
async transcode (input, outputs) { | ||
const filteredOutputs = await this.maybeRemoveExistingOutputs(outputs); | ||
if (!filteredOutputs.length) return false; | ||
const jobId = await this.createTranscoderJob(key, filteredOutputs); | ||
return this.waitForTranscoderJob(key, jobId); | ||
const jobId = await this.createTranscoderJob(input, filteredOutputs); | ||
return this.waitForTranscoderJob(input.key, jobId); | ||
} | ||
@@ -86,6 +89,15 @@ | ||
*/ | ||
async createTranscoderJob (key, outputs) { | ||
async createTranscoderJob (input, outputs) { | ||
const { key, start = 0, duration } = input; | ||
const { pipelineId } = this.config; | ||
const params = { | ||
Input: { Key: key }, | ||
Input: { | ||
Key: key, | ||
...((start > 0 || duration) && { | ||
TimeSpan: { | ||
...(start > 0 && { StartTime: Number(start).toFixed(3) }), | ||
...(duration && { Duration: Number(duration).toFixed(3) }) | ||
} | ||
}) | ||
}, | ||
PipelineId: pipelineId, | ||
@@ -152,7 +164,10 @@ Outputs: outputs.map(({ key, presetId, thumbnailPattern }) => ({ | ||
async function transcode (key, outputs, config) { | ||
async function transcode (input, outputs, config) { | ||
if (typeof input === 'string') { | ||
input = { key: input }; | ||
} | ||
const transcoder = new AwsTranscoder(config); | ||
return transcoder.transcode(key, outputs); | ||
return transcoder.transcode(input, outputs); | ||
} | ||
module.exports = transcode; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11045
159
88
2