Skip to content
This repository was archived by the owner on Nov 3, 2022. It is now read-only.

Commit 54bac38

Browse files
committed
WIP
1 parent 90bf890 commit 54bac38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+8151
-8257
lines changed

.editorconfig

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@ root = true
77
[*]
88
end_of_line = lf
99
insert_final_newline = true
10-
indent_style = tab
11-
indent_size = 4
10+
indent_style = space
11+
indent_size = 2
1212

1313
# Matches multiple files with brace expansion notation
1414
# Set default charset
1515
[*.js]
1616
charset = utf-8
17-
18-
# Matches the exact files either package.json or .travis.yml
19-
[{package.json,.travis.yml}]
20-
indent_style = space
21-
indent_size = 2

.travis.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# 4.0.0
2+
- Add CDK support
3+
- Localstack support for testing
4+
- Rewrite with TypeScript
5+
- Dropped support for non-AWS providers
6+
- Use Docker
7+
- Add Docker Lock
8+
- Use gts for code style
9+
110
# 3.2.0
211
- Travis
312
- Install latest yarn

README.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
> An ~~[AWS Lambda](http://aws.amazon.com/lambda/)~~ Event-driven function that resizes videos and outputs thumbnails using [FFmpeg](https://www.ffmpeg.org/). This function is meant for short-duration videos. If you need to transcode long videos, check out [AWS Elastic Transcoder](http://aws.amazon.com/elastictranscoder/).
1+
> An [AWS Lambda](http://aws.amazon.com/lambda/) function that resizes videos and outputs thumbnails using [FFmpeg](https://www.ffmpeg.org/). This function is meant for short-duration videos. If you need to transcode long videos, check out [AWS Elastic Transcoder](http://aws.amazon.com/elastictranscoder/).
22
33
[![Dependency Status](https://david-dm.org/binoculars/aws-lambda-ffmpeg.svg)](https://david-dm.org/binoculars/aws-lambda-ffmpeg)
44
[![devDependency Status](https://david-dm.org/binoculars/aws-lambda-ffmpeg/dev-status.svg)](https://david-dm.org/binoculars/aws-lambda-ffmpeg#info=devDependencies)
55
[![Known Vulnerabilities](https://snyk.io/test/github/binoculars/aws-lambda-ffmpeg/badge.svg)](https://snyk.io/test/github/binoculars/aws-lambda-ffmpeg)
6-
[![Greenkeeper badge](https://badges.greenkeeper.io/binoculars/aws-lambda-ffmpeg.svg)](https://greenkeeper.io/)
76

87
- Master: [![Build Status](https://travis-ci.org/binoculars/aws-lambda-ffmpeg.svg?branch=master)](https://travis-ci.org/binoculars/aws-lambda-ffmpeg)
98
- Develop: [![Build Status](https://travis-ci.org/binoculars/aws-lambda-ffmpeg.svg?branch=develop)](https://travis-ci.org/binoculars/aws-lambda-ffmpeg)
@@ -24,12 +23,6 @@ The different platforms have different naming conventions for their services. To
2423
1. Outputs a scaled video file and a thumbnail image
2524
1. Uploads both files to the destination bucket
2625

27-
# Supported Platforms
28-
- [x] Amazon Web Services (aws) Lambda
29-
- [x] Google Cloud Platform (gcp) Cloud Functions (Alpha)
30-
- [ ] IBM (ibm) OpenWhisk (Not started)
31-
- [ ] Microsoft Azure (msa) Functions (Still some work to do here)
32-
3326
# Setup
3427
1. Install node.js, preferably through [nvm](https://github.com/creationix/nvm). Each platform service uses a specific version of Node.js.
3528
1. Clone this repo `git clone ...`
@@ -58,9 +51,6 @@ At minimum, you need to modify:
5851
- When switching among the platforms, reinstall the node modules if the runtime supports a different version of Node.js.
5952
- See the platform-specific notes
6053

61-
## Gotchas
62-
- Gzipping videos will cause Safari errors in playback. Don't enable gzip unless you don't care about supporting Safari.
63-
6454
# Platform-specific notes
6555
## AWS Lambda
6656
- [Version information](https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html)
@@ -77,13 +67,12 @@ export AWS_REGION=us-east-1
7767
export DESTINATION_BUCKET=destination-bucket
7868
# Note that the following variable is single-quote escaped. Use $KEY_PREFIX to get the filename minus the extension.
7969
export FFMPEG_ARGS=$'-c:a copy -vf scale=\'min(320\\,iw):-2\' -movflags +faststart -metadata description=http://my.site/$KEY_PREFIX.mp4 out.mp4 -vf thumbnail -vf scale=\'min(320\\,iw):-2\' -vframes 1 out.png'
80-
export USE_GZIP=false
8170
export MIME_TYPES='{"png":"image/png","mp4":"video/mp4"}'
8271
export VIDEO_MAX_DURATION='30'
8372
export SSE="aws:kms" # or "aes256" if you want to put the video into an encrypted bucket
8473
export SSE_KEY_ID="some kms key id" # if SSE="aws:kms" you must provide this key id too
8574
# Node version
86-
nvm use 6.10 # This is subject to change
75+
nvm use 14 # This is subject to change
8776
# Babel-node test script
8877
node node_modules/babel-cli/bin/babel-node.js test/aws.js
8978
```
@@ -105,7 +94,6 @@ export SOURCE_BUCKET=source-bucket
10594
export DESTINATION_BUCKET=destination-bucket
10695
# Note that the following variable is single-quote escaped. Use $KEY_PREFIX to get the filename minus the extension.
10796
export FFMPEG_ARGS=$'-c:a copy -vf scale=\'min(320\\,iw):-2\' -movflags +faststart -metadata description=http://my.site/$KEY_PREFIX.mp4 out.mp4 -vf thumbnail -vf scale=\'min(320\\,iw):-2\' -vframes 1 out.png'
108-
export USE_GZIP=false # can be true or false
10997
export MIME_TYPES='{"png":"image/png","mp4":"video/mp4"}' # must be a JSON object with "extension": "mimeType" as the key/value pairs
11098
export VIDEO_MAX_DURATION='30' # must be a number
11199
```

cdk/.dockerignore

Whitespace-only changes.

cdk/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.js
2+
!jest.config.js
3+
*.d.ts
4+
node_modules
5+
6+
# CDK asset staging directory
7+
.cdk.staging
8+
cdk.out

cdk/.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.ts
2+
!*.d.ts
3+
4+
# CDK asset staging directory
5+
.cdk.staging
6+
cdk.out

cdk/Dockerfile

Whitespace-only changes.

cdk/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Welcome to your CDK TypeScript project!
2+
3+
This is a blank project for TypeScript development with CDK.
4+
5+
The `cdk.json` file tells the CDK Toolkit how to execute your app.
6+
7+
## Useful commands
8+
9+
* `npm run build` compile typescript to js
10+
* `npm run watch` watch for changes and compile
11+
* `npm run test` perform the jest unit tests
12+
* `cdk deploy` deploy this stack to your default AWS account/region
13+
* `cdk diff` compare deployed stack with current state
14+
* `cdk synth` emits the synthesized CloudFormation template

cdk/bin/cdk.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
import 'source-map-support/register';
3+
import * as cdk from '@aws-cdk/core';
4+
import { CdkStack } from '../lib/cdk-stack';
5+
6+
const app = new cdk.App();
7+
new CdkStack(app, 'CdkStack');

cdk/cdk.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"app": "npx ts-node --prefer-ts-exts bin/cdk.ts",
3+
"context": {
4+
"@aws-cdk/core:enableStackNameDuplicates": "true",
5+
"aws-cdk:enableDiffNoFail": "true",
6+
"@aws-cdk/core:stackRelativeExports": "true",
7+
"@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true,
8+
"@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true,
9+
"@aws-cdk/aws-kms:defaultKeyPolicies": true,
10+
"@aws-cdk/aws-s3:grantWriteWithoutAcl": true,
11+
"@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount": true
12+
}
13+
}

cdk/jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
roots: ['<rootDir>/test'],
3+
testMatch: ['**/*.test.ts'],
4+
transform: {
5+
'^.+\\.tsx?$': 'ts-jest'
6+
}
7+
};

cdk/lib/cdk-stack.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as cdk from '@aws-cdk/core';
2+
3+
export class CdkStack extends cdk.Stack {
4+
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
5+
super(scope, id, props);
6+
7+
// The code that defines your stack goes here
8+
}
9+
}

cdk/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "cdk",
3+
"version": "0.1.0",
4+
"bin": {
5+
"cdk": "bin/cdk.js"
6+
},
7+
"scripts": {
8+
"build": "tsc",
9+
"watch": "tsc -w",
10+
"test": "jest",
11+
"cdk": "cdk"
12+
},
13+
"devDependencies": {
14+
"@aws-cdk/assert": "1.92.0",
15+
"@types/jest": "^26.0.10",
16+
"@types/node": "10.17.27",
17+
"jest": "^26.4.2",
18+
"ts-jest": "^26.2.0",
19+
"aws-cdk": "1.92.0",
20+
"ts-node": "^9.0.0",
21+
"typescript": "~3.9.7"
22+
},
23+
"dependencies": {
24+
"@aws-cdk/core": "1.92.0",
25+
"source-map-support": "^0.5.16"
26+
}
27+
}

cdk/test/cdk.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expect as expectCDK, matchTemplate, MatchStyle } from '@aws-cdk/assert';
2+
import * as cdk from '@aws-cdk/core';
3+
import * as Cdk from '../lib/cdk-stack';
4+
5+
test('Empty Stack', () => {
6+
const app = new cdk.App();
7+
// WHEN
8+
const stack = new Cdk.CdkStack(app, 'MyTestStack');
9+
// THEN
10+
expectCDK(stack).to(matchTemplate({
11+
"Resources": {}
12+
}, MatchStyle.EXACT))
13+
});

cdk/tsconfig.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2018",
4+
"module": "commonjs",
5+
"lib": ["es2018"],
6+
"declaration": true,
7+
"strict": true,
8+
"noImplicitAny": true,
9+
"strictNullChecks": true,
10+
"noImplicitThis": true,
11+
"alwaysStrict": true,
12+
"noUnusedLocals": false,
13+
"noUnusedParameters": false,
14+
"noImplicitReturns": true,
15+
"noFallthroughCasesInSwitch": false,
16+
"inlineSourceMap": true,
17+
"inlineSources": true,
18+
"experimentalDecorators": true,
19+
"strictPropertyInitialization": false,
20+
"typeRoots": ["./node_modules/@types"]
21+
},
22+
"exclude": ["cdk.out"]
23+
}

cdk/yarn-error.log

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Arguments:
2+
/Users/barrett/.nvm/versions/node/v14.2.0/bin/node /usr/local/Cellar/yarn/1.22.5/libexec/bin/yarn.js init
3+
4+
PATH:
5+
/Users/barrett/.nvm/versions/node/v14.2.0/bin:/Users/barrett/.nvm/versions/node/v14.2.0/bin:/Users/barrett/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/barrett/.nvm/versions/node/v14.2.0/bin:/Users/barrett/.cargo/bin:/Users/barrett/.local/bin:/Users/barrett/.local/bin:/Users/barrett/.local/bin
6+
7+
Yarn version:
8+
1.22.5
9+
10+
Node version:
11+
14.2.0
12+
13+
Platform:
14+
darwin x64
15+
16+
Trace:
17+
Error: canceled
18+
at Interface.<anonymous> (/usr/local/Cellar/yarn/1.22.5/libexec/lib/cli.js:137009:13)
19+
at Interface.emit (events.js:315:20)
20+
at Interface._ttyWrite (readline.js:873:16)
21+
at ReadStream.onkeypress (readline.js:213:10)
22+
at ReadStream.emit (events.js:315:20)
23+
at emitKeys (internal/readline/utils.js:335:14)
24+
at emitKeys.next (<anonymous>)
25+
at ReadStream.onData (readline.js:1140:36)
26+
at ReadStream.emit (events.js:315:20)
27+
at addChunk (_stream_readable.js:302:12)
28+
29+
npm manifest:
30+
{
31+
"name": "cdk",
32+
"version": "0.1.0",
33+
"bin": {
34+
"cdk": "bin/cdk.js"
35+
},
36+
"scripts": {
37+
"build": "tsc",
38+
"watch": "tsc -w",
39+
"test": "jest",
40+
"cdk": "cdk"
41+
},
42+
"devDependencies": {
43+
"@aws-cdk/assert": "1.92.0",
44+
"@types/jest": "^26.0.10",
45+
"@types/node": "10.17.27",
46+
"jest": "^26.4.2",
47+
"ts-jest": "^26.2.0",
48+
"aws-cdk": "1.92.0",
49+
"ts-node": "^9.0.0",
50+
"typescript": "~3.9.7"
51+
},
52+
"dependencies": {
53+
"@aws-cdk/core": "1.92.0",
54+
"source-map-support": "^0.5.16"
55+
}
56+
}
57+
58+
yarn manifest:
59+
No manifest
60+
61+
Lockfile:
62+
No lockfile

0 commit comments

Comments
 (0)