@twick/cloud-export-video 0.14.17 → 0.14.20
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 +56 -96
- package/package.json +8 -11
package/README.md
CHANGED
|
@@ -1,129 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
# @twick/cloud-export-video
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Export Twick video projects to MP4 format using serverless rendering.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Converts Twick project JSON into MP4 video files using Chromium and ffmpeg in AWS Lambda containers. No server management required—deploy as a serverless function that scales automatically.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
npm install -D @twick/cloud-export-video
|
|
9
|
-
```
|
|
7
|
+
## What Problem Does This Solve?
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
- **Serverless video rendering** — Export videos without managing servers or infrastructure
|
|
10
|
+
- **Programmatic video generation** — Convert Twick project JSON to MP4 via API calls
|
|
11
|
+
- **Scalable processing** — AWS Lambda handles concurrent exports automatically
|
|
12
|
+
- **Cost-effective** — Pay only for rendering time, no idle server costs
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
## Input → Output
|
|
15
|
+
|
|
16
|
+
**Input:** Twick project JSON + optional media files
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"project": { /* Twick project JSON */ },
|
|
20
|
+
"mediaFiles": [ /* Optional media file URLs */ ]
|
|
21
|
+
}
|
|
15
22
|
```
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
**Output:** MP4 video file (base64 encoded or file path)
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
- `build <image> [dir]`: Build a Docker image from `[dir]` (default `./twick-export-video-aws`).
|
|
21
|
-
- `ecr-login <region> <accountId>`: Log in Docker to your AWS ECR registry.
|
|
22
|
-
- `push <image> <region> <accountId>`: Tag and push the image to ECR. The repository must already exist.
|
|
26
|
+
**Where it runs:** AWS Lambda container image (Linux/AMD64)
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
## Installation
|
|
25
29
|
|
|
26
30
|
```bash
|
|
27
|
-
|
|
28
|
-
npx twick-export-video init
|
|
29
|
-
|
|
30
|
-
# 2) Build an image
|
|
31
|
-
npx twick-export-video build twick-export-video:latest
|
|
32
|
-
|
|
33
|
-
# 3) Login to ECR
|
|
34
|
-
npx twick-export-video ecr-login us-east-1 123456789012
|
|
35
|
-
|
|
36
|
-
# 4) Push (assumes an ECR repo named `twick-export-video` exists)
|
|
37
|
-
npx twick-export-video push twick-export-video:latest us-east-1 123456789012
|
|
31
|
+
npm install -D @twick/cloud-export-video
|
|
38
32
|
```
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
This package ships with an AWS Lambda container template (Dockerfile + handler).
|
|
34
|
+
## Quick Start
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
In the `packages/cloud-functions/export-video` directory:
|
|
36
|
+
### 1. Scaffold AWS Lambda Template
|
|
47
37
|
|
|
48
38
|
```bash
|
|
49
|
-
|
|
39
|
+
npx twick-export-video init
|
|
50
40
|
```
|
|
51
41
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
This creates a `twick-export-video-aws` directory with:
|
|
43
|
+
- Dockerfile for Lambda container
|
|
44
|
+
- Lambda handler code
|
|
45
|
+
- Minimal package.json
|
|
55
46
|
|
|
56
|
-
|
|
57
|
-
- AWS CLI configured with appropriate credentials
|
|
58
|
-
- Docker installed and running
|
|
47
|
+
### 2. Build Docker Image
|
|
59
48
|
|
|
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
49
|
```bash
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
REPOSITORY_NAME="twick-export-video"
|
|
101
|
-
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
|
50
|
+
npx twick-export-video build twick-export-video:latest
|
|
51
|
+
```
|
|
102
52
|
|
|
103
|
-
|
|
104
|
-
docker buildx build --platform linux/amd64 -t twick-export-video:latest -f platform/aws/Dockerfile .
|
|
53
|
+
### 3. Deploy to AWS Lambda
|
|
105
54
|
|
|
55
|
+
```bash
|
|
106
56
|
# Login to ECR
|
|
107
|
-
|
|
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
|
|
57
|
+
npx twick-export-video ecr-login us-east-1 YOUR_ACCOUNT_ID
|
|
111
58
|
|
|
112
|
-
#
|
|
113
|
-
|
|
114
|
-
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$REPOSITORY_NAME:latest
|
|
59
|
+
# Push to ECR
|
|
60
|
+
npx twick-export-video push twick-export-video:latest us-east-1 YOUR_ACCOUNT_ID
|
|
115
61
|
```
|
|
116
62
|
|
|
117
|
-
|
|
63
|
+
Then create a Lambda function using the ECR image URI.
|
|
118
64
|
|
|
119
|
-
|
|
120
|
-
- The Dockerfile is based on `revideo/aws-lambda-base-image` and prepares Chromium and ffmpeg for headless rendering.
|
|
121
|
-
- The handler expects an `event.arguments.input` payload with `{ project, mediaFiles? }`.
|
|
122
|
-
- The response is a `video/mp4` base64 body, or a text file on error.
|
|
65
|
+
## Deployment (High Level)
|
|
123
66
|
|
|
124
|
-
|
|
67
|
+
1. **Scaffold** the Lambda container template
|
|
68
|
+
2. **Build** the Docker image (includes Chromium + ffmpeg)
|
|
69
|
+
3. **Push** to AWS ECR (Elastic Container Registry)
|
|
70
|
+
4. **Create Lambda function** using the ECR image
|
|
71
|
+
5. **Configure** memory (recommended: 3GB+) and timeout (5+ minutes)
|
|
125
72
|
|
|
126
|
-
The
|
|
73
|
+
The Lambda handler expects:
|
|
74
|
+
- **Event format:** `{ arguments: { input: { project, mediaFiles? } } }`
|
|
75
|
+
- **Response:** `video/mp4` base64 body, or error text
|
|
76
|
+
|
|
77
|
+
## Programmatic Usage
|
|
78
|
+
|
|
79
|
+
Use the core renderer directly (without Lambda):
|
|
127
80
|
|
|
128
81
|
```js
|
|
129
82
|
import renderTwickVideo from '@twick/cloud-export-video/core/renderer.js';
|
|
@@ -131,4 +84,11 @@ import renderTwickVideo from '@twick/cloud-export-video/core/renderer.js';
|
|
|
131
84
|
const resultPath = await renderTwickVideo(project, { outFile: 'my.mp4' });
|
|
132
85
|
```
|
|
133
86
|
|
|
87
|
+
## Technical Details
|
|
88
|
+
|
|
89
|
+
- **Base image:** `revideo/aws-lambda-base-image` (includes Chromium and ffmpeg)
|
|
90
|
+
- **Platform:** Linux/AMD64
|
|
91
|
+
- **Handler:** `platform/aws/handler.handler`
|
|
92
|
+
- **Response format:** Base64-encoded MP4 or error text
|
|
134
93
|
|
|
94
|
+
For detailed deployment steps, see the complete example script in the repository.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twick/cloud-export-video",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.20",
|
|
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",
|
|
@@ -45,21 +45,18 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@sparticuz/chromium": "^129.0.0",
|
|
48
|
-
"@twick/2d": "0.14.
|
|
49
|
-
"@twick/core": "0.14.
|
|
50
|
-
"@twick/ffmpeg": "0.14.
|
|
51
|
-
"@twick/renderer": "0.14.
|
|
52
|
-
"@twick/ui": "0.14.
|
|
53
|
-
"@twick/vite-plugin": "0.14.
|
|
54
|
-
"@twick/visualizer": "0.14.
|
|
48
|
+
"@twick/2d": "^0.14.20",
|
|
49
|
+
"@twick/core": "^0.14.20",
|
|
50
|
+
"@twick/ffmpeg": "^0.14.20",
|
|
51
|
+
"@twick/renderer": "^0.14.20",
|
|
52
|
+
"@twick/ui": "^0.14.20",
|
|
53
|
+
"@twick/vite-plugin": "^0.14.20",
|
|
54
|
+
"@twick/visualizer": "^0.14.20",
|
|
55
55
|
"@aws-sdk/client-s3": "^3.620.0",
|
|
56
56
|
"ffmpeg-static": "^5.2.0",
|
|
57
57
|
"fluent-ffmpeg": "^2.1.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"typescript": "~5.4.5"
|
|
61
|
-
},
|
|
62
|
-
"peerDependencies": {
|
|
63
|
-
"puppeteer": ">=22"
|
|
64
61
|
}
|
|
65
62
|
}
|