-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathresize-video.js
52 lines (40 loc) · 1.4 KB
/
resize-video.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const Shotstack = require('shotstack-sdk');
const defaultClient = Shotstack.ApiClient.instance;
const DeveloperKey = defaultClient.authentications['DeveloperKey'];
const api = new Shotstack.IngestApi();
const apiUrlBase = 'https://api.shotstack.io/ingest/';
let apiUrl = apiUrlBase + 'stage';
if (!process.env.SHOTSTACK_KEY) {
console.log('API Key is required. Set using: export SHOTSTACK_KEY=your_key_here');
process.exit(1);
}
if (process.env.SHOTSTACK_CREATE_HOST) {
apiUrl = process.env.SHOTSTACK_CREATE_HOST;
}
if (process.env.SHOTSTACK_ENV) {
apiUrl = apiUrlBase + process.env.SHOTSTACK_ENV;
}
defaultClient.basePath = apiUrl;
DeveloperKey.apiKey = process.env.SHOTSTACK_KEY;
const size = new Shotstack.Size;
size
.setHeight(720);
const rendition = new Shotstack.Rendition;
rendition
.setSize(size);
const outputs = new Shotstack.Outputs;
outputs
.setRenditions([rendition]);
const source = new Shotstack.Source;
source
.setUrl('https://shotstack-assets.s3.ap-southeast-2.amazonaws.com/footage/cliffs-sunset.mp4')
.setOutputs(outputs);
api.postSource(source).then((source) => {
const id = source.data.id
console.log(`Request 'queued' with id: ${id}\n`);
console.log('>> Now check the progress by running:');
console.log(`>> node examples/ingest-api/status.js ${id}`);
}, (error) => {
console.error('Request failed: ', error);
process.exit(1);
});