@twick/cloud-export-video 0.14.14 → 0.14.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -1
- package/core/renderer.js +1 -1
- package/package.json +9 -8
- package/platform/aws/Dockerfile +1 -1
- package/platform/aws/handler.js +18 -2
package/README.md
CHANGED
|
@@ -37,8 +37,86 @@ npx twick-export-video ecr-login us-east-1 123456789012
|
|
|
37
37
|
npx twick-export-video push twick-export-video:latest us-east-1 123456789012
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
### AWS Lambda (container)
|
|
40
|
+
### AWS Lambda (container) usage
|
|
41
41
|
|
|
42
|
+
This package ships with an AWS Lambda container template (Dockerfile + handler).
|
|
43
|
+
|
|
44
|
+
#### Build image
|
|
45
|
+
|
|
46
|
+
In the `packages/cloud-functions/export-video` directory:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
docker buildx build --platform linux/amd64 -t twick-export-video:latest -f platform/aws/Dockerfile .
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
#### Push image to AWS ECR
|
|
53
|
+
|
|
54
|
+
To deploy the container image to AWS Elastic Container Registry (ECR) for use with Lambda:
|
|
55
|
+
|
|
56
|
+
**Prerequisites:**
|
|
57
|
+
- AWS CLI configured with appropriate credentials
|
|
58
|
+
- Docker installed and running
|
|
59
|
+
|
|
60
|
+
**Steps:**
|
|
61
|
+
|
|
62
|
+
1. **Get your AWS Account ID:**
|
|
63
|
+
```bash
|
|
64
|
+
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
2. **Set your AWS region and repository name:**
|
|
68
|
+
```bash
|
|
69
|
+
AWS_REGION="your-aws-region" # e.g., ap-south-1, us-east-1
|
|
70
|
+
REPOSITORY_NAME="twick-export-video"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
3. **Login to ECR:**
|
|
74
|
+
```bash
|
|
75
|
+
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
4. **Create ECR repository (if it doesn't exist):**
|
|
79
|
+
```bash
|
|
80
|
+
aws ecr create-repository \
|
|
81
|
+
--repository-name $REPOSITORY_NAME \
|
|
82
|
+
--image-scanning-configuration scanOnPush=true \
|
|
83
|
+
--region $AWS_REGION
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
5. **Tag the image:**
|
|
87
|
+
```bash
|
|
88
|
+
docker tag twick-export-video:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$REPOSITORY_NAME:latest
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
6. **Push the image:**
|
|
92
|
+
```bash
|
|
93
|
+
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$REPOSITORY_NAME:latest
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Complete example script:**
|
|
97
|
+
```bash
|
|
98
|
+
#!/bin/bash
|
|
99
|
+
AWS_REGION="ap-south-1"
|
|
100
|
+
REPOSITORY_NAME="twick-export-video"
|
|
101
|
+
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
|
102
|
+
|
|
103
|
+
# Build the image
|
|
104
|
+
docker buildx build --platform linux/amd64 -t twick-export-video:latest -f platform/aws/Dockerfile .
|
|
105
|
+
|
|
106
|
+
# Login to ECR
|
|
107
|
+
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
|
|
108
|
+
|
|
109
|
+
# Create repository if it doesn't exist
|
|
110
|
+
aws ecr create-repository --repository-name $REPOSITORY_NAME --image-scanning-configuration scanOnPush=true --region $AWS_REGION 2>/dev/null || true
|
|
111
|
+
|
|
112
|
+
# Tag and push
|
|
113
|
+
docker tag twick-export-video:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$REPOSITORY_NAME:latest
|
|
114
|
+
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$REPOSITORY_NAME:latest
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
After pushing, you can use the ECR image URI (`$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$REPOSITORY_NAME:latest`) when creating or updating your Lambda function.
|
|
118
|
+
|
|
119
|
+
**Notes:**
|
|
42
120
|
- The Dockerfile is based on `revideo/aws-lambda-base-image` and prepares Chromium and ffmpeg for headless rendering.
|
|
43
121
|
- The handler expects an `event.arguments.input` payload with `{ project, mediaFiles? }`.
|
|
44
122
|
- The response is a `video/mp4` base64 body, or a text file on error.
|
package/core/renderer.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twick/cloud-export-video",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.16",
|
|
4
4
|
"description": "Twick cloud function for exporting video with platform-specific templates (AWS Lambda container)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "core/renderer.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./core/renderer.js",
|
|
9
9
|
"./aws": "./platform/aws/handler.js",
|
|
10
|
+
"./aws/cjs": "./platform/aws/handler.cjs",
|
|
10
11
|
"./platform/aws/*": "./platform/aws/*"
|
|
11
12
|
},
|
|
12
13
|
"bin": {
|
|
@@ -43,13 +44,13 @@
|
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@sparticuz/chromium": "^129.0.0",
|
|
46
|
-
"@twick/2d": "0.14.
|
|
47
|
-
"@twick/core": "0.14.
|
|
48
|
-
"@twick/ffmpeg": "0.14.
|
|
49
|
-
"@twick/renderer": "0.14.
|
|
50
|
-
"@twick/ui": "0.14.
|
|
51
|
-
"@twick/vite-plugin": "0.14.
|
|
52
|
-
"@twick/visualizer": "0.14.
|
|
47
|
+
"@twick/2d": "0.14.16",
|
|
48
|
+
"@twick/core": "0.14.16",
|
|
49
|
+
"@twick/ffmpeg": "0.14.16",
|
|
50
|
+
"@twick/renderer": "0.14.16",
|
|
51
|
+
"@twick/ui": "0.14.16",
|
|
52
|
+
"@twick/vite-plugin": "0.14.16",
|
|
53
|
+
"@twick/visualizer": "0.14.16",
|
|
53
54
|
"@aws-sdk/client-s3": "^3.620.0",
|
|
54
55
|
"ffmpeg-static": "^5.2.0",
|
|
55
56
|
"fluent-ffmpeg": "^2.1.3"
|
package/platform/aws/Dockerfile
CHANGED
package/platform/aws/handler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
|
|
2
|
-
import renderTwickVideo from '
|
|
2
|
+
import { renderTwickVideo } from '@twick/cloud-export-video';
|
|
3
3
|
|
|
4
4
|
const s3Client = new S3Client({
|
|
5
5
|
region: process.env.EXPORT_VIDEO_S3_REGION || process.env.AWS_REGION || 'us-east-1',
|
|
@@ -107,11 +107,25 @@ const buildPublicUrl = ({ bucket, key, region, baseUrl }) => {
|
|
|
107
107
|
* Returns: JSON payload containing the uploaded video URL and metadata
|
|
108
108
|
*/
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
const handler = async (event) => {
|
|
111
111
|
console.log('Video processor function invoked');
|
|
112
112
|
console.log('Event:', JSON.stringify(event));
|
|
113
113
|
const projectData = event.arguments || {};
|
|
114
114
|
|
|
115
|
+
if(!renderTwickVideo) {
|
|
116
|
+
return {
|
|
117
|
+
statusCode: 500,
|
|
118
|
+
headers: {
|
|
119
|
+
'Content-Type': 'application/json',
|
|
120
|
+
'Access-Control-Allow-Origin': '*',
|
|
121
|
+
},
|
|
122
|
+
body: JSON.stringify({
|
|
123
|
+
error: 'Failed to load renderTwickVideo',
|
|
124
|
+
message: 'Failed to load renderTwickVideo',
|
|
125
|
+
}),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
115
129
|
try {
|
|
116
130
|
// Validate required fields
|
|
117
131
|
if (!projectData) {
|
|
@@ -293,3 +307,5 @@ ${mediaFiles.map((file, index) => ` ${index + 1}. ${file.filename} (${file.data
|
|
|
293
307
|
};
|
|
294
308
|
}
|
|
295
309
|
};
|
|
310
|
+
|
|
311
|
+
module.exports.handler = handler;
|