varg.ai-sdk 0.1.1 → 0.4.0-alpha.1
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/.claude/settings.local.json +1 -1
- package/.env.example +3 -0
- package/.github/workflows/ci.yml +23 -0
- package/.husky/README.md +102 -0
- package/.husky/commit-msg +6 -0
- package/.husky/pre-commit +9 -0
- package/.husky/pre-push +6 -0
- package/.size-limit.json +8 -0
- package/.test-hooks.ts +5 -0
- package/CLAUDE.md +10 -3
- package/CONTRIBUTING.md +150 -0
- package/LICENSE.md +53 -0
- package/README.md +56 -209
- package/SKILLS.md +26 -10
- package/biome.json +7 -1
- package/bun.lock +1286 -0
- package/commitlint.config.js +22 -0
- package/docs/index.html +1130 -0
- package/docs/prompting.md +326 -0
- package/docs/react.md +834 -0
- package/docs/sdk.md +812 -0
- package/ffmpeg/CLAUDE.md +68 -0
- package/package.json +43 -10
- package/pipeline/cookbooks/scripts/animate-frames-parallel.ts +84 -0
- package/pipeline/cookbooks/scripts/combine-scenes.sh +53 -0
- package/pipeline/cookbooks/scripts/generate-frames-parallel.ts +99 -0
- package/pipeline/cookbooks/scripts/still-to-video.sh +37 -0
- package/pipeline/cookbooks/text-to-tiktok.md +669 -0
- package/pipeline/cookbooks/trendwatching.md +156 -0
- package/plan.md +281 -0
- package/scripts/.gitkeep +0 -0
- package/src/ai-sdk/cache.ts +142 -0
- package/src/ai-sdk/examples/cached-generation.ts +53 -0
- package/src/ai-sdk/examples/duet-scene-4.ts +53 -0
- package/src/ai-sdk/examples/duet-scene-5-audio.ts +32 -0
- package/src/ai-sdk/examples/duet-video.ts +56 -0
- package/src/ai-sdk/examples/editly-composition.ts +63 -0
- package/src/ai-sdk/examples/editly-test.ts +57 -0
- package/src/ai-sdk/examples/editly-video-test.ts +52 -0
- package/src/ai-sdk/examples/fal-lipsync.ts +43 -0
- package/src/ai-sdk/examples/higgsfield-image.ts +61 -0
- package/src/ai-sdk/examples/music-generation.ts +19 -0
- package/src/ai-sdk/examples/openai-sora.ts +34 -0
- package/src/ai-sdk/examples/replicate-bg-removal.ts +52 -0
- package/src/ai-sdk/examples/simpsons-scene.ts +61 -0
- package/src/ai-sdk/examples/talking-lion.ts +55 -0
- package/src/ai-sdk/examples/video-generation.ts +39 -0
- package/src/ai-sdk/examples/workflow-animated-girl.ts +104 -0
- package/src/ai-sdk/examples/workflow-before-after.ts +114 -0
- package/src/ai-sdk/examples/workflow-character-grid.ts +112 -0
- package/src/ai-sdk/examples/workflow-slideshow.ts +161 -0
- package/src/ai-sdk/file-cache.ts +112 -0
- package/src/ai-sdk/file.ts +238 -0
- package/src/ai-sdk/generate-element.ts +92 -0
- package/src/ai-sdk/generate-music.ts +46 -0
- package/src/ai-sdk/generate-video.ts +165 -0
- package/src/ai-sdk/index.ts +72 -0
- package/src/ai-sdk/music-model.ts +110 -0
- package/src/ai-sdk/providers/editly/editly.test.ts +1108 -0
- package/src/ai-sdk/providers/editly/ffmpeg.ts +60 -0
- package/src/ai-sdk/providers/editly/index.ts +817 -0
- package/src/ai-sdk/providers/editly/layers.ts +776 -0
- package/src/ai-sdk/providers/editly/plan.md +144 -0
- package/src/ai-sdk/providers/editly/types.ts +328 -0
- package/src/ai-sdk/providers/elevenlabs-provider.ts +255 -0
- package/src/ai-sdk/providers/fal-provider.ts +512 -0
- package/src/ai-sdk/providers/higgsfield.ts +379 -0
- package/src/ai-sdk/providers/openai.ts +251 -0
- package/src/ai-sdk/providers/replicate.ts +16 -0
- package/src/ai-sdk/video-model.ts +185 -0
- package/src/cli/commands/find.tsx +137 -0
- package/src/cli/commands/help.tsx +85 -0
- package/src/cli/commands/index.ts +6 -0
- package/src/cli/commands/list.tsx +238 -0
- package/src/cli/commands/render.tsx +71 -0
- package/src/cli/commands/run.tsx +511 -0
- package/src/cli/commands/which.tsx +253 -0
- package/src/cli/index.ts +114 -0
- package/src/cli/quiet.ts +44 -0
- package/src/cli/types.ts +32 -0
- package/src/cli/ui/components/Badge.tsx +29 -0
- package/src/cli/ui/components/DataTable.tsx +51 -0
- package/src/cli/ui/components/Header.tsx +23 -0
- package/src/cli/ui/components/HelpBlock.tsx +44 -0
- package/src/cli/ui/components/KeyValue.tsx +33 -0
- package/src/cli/ui/components/OptionRow.tsx +81 -0
- package/src/cli/ui/components/Separator.tsx +23 -0
- package/src/cli/ui/components/StatusBox.tsx +108 -0
- package/src/cli/ui/components/VargBox.tsx +51 -0
- package/src/cli/ui/components/VargProgress.tsx +36 -0
- package/src/cli/ui/components/VargSpinner.tsx +34 -0
- package/src/cli/ui/components/VargText.tsx +56 -0
- package/src/cli/ui/components/index.ts +19 -0
- package/src/cli/ui/index.ts +12 -0
- package/src/cli/ui/render.ts +35 -0
- package/src/cli/ui/theme.ts +63 -0
- package/src/cli/utils.ts +78 -0
- package/src/core/executor/executor.ts +201 -0
- package/src/core/executor/index.ts +13 -0
- package/src/core/executor/job.ts +214 -0
- package/src/core/executor/pipeline.ts +222 -0
- package/src/core/index.ts +11 -0
- package/src/core/registry/index.ts +9 -0
- package/src/core/registry/loader.ts +149 -0
- package/src/core/registry/registry.ts +221 -0
- package/src/core/registry/resolver.ts +206 -0
- package/src/core/schema/helpers.ts +134 -0
- package/src/core/schema/index.ts +8 -0
- package/src/core/schema/shared.ts +102 -0
- package/src/core/schema/types.ts +279 -0
- package/src/core/schema/validator.ts +92 -0
- package/src/definitions/actions/captions.ts +261 -0
- package/src/definitions/actions/edit.ts +298 -0
- package/src/definitions/actions/image.ts +125 -0
- package/src/definitions/actions/index.ts +114 -0
- package/src/definitions/actions/music.ts +205 -0
- package/src/definitions/actions/sync.ts +128 -0
- package/{action/transcribe/index.ts → src/definitions/actions/transcribe.ts} +58 -68
- package/src/definitions/actions/upload.ts +111 -0
- package/src/definitions/actions/video.ts +163 -0
- package/src/definitions/actions/voice.ts +119 -0
- package/src/definitions/index.ts +23 -0
- package/src/definitions/models/elevenlabs.ts +50 -0
- package/src/definitions/models/flux.ts +56 -0
- package/src/definitions/models/index.ts +36 -0
- package/src/definitions/models/kling.ts +56 -0
- package/src/definitions/models/llama.ts +54 -0
- package/src/definitions/models/nano-banana-pro.ts +102 -0
- package/src/definitions/models/sonauto.ts +68 -0
- package/src/definitions/models/soul.ts +65 -0
- package/src/definitions/models/wan.ts +54 -0
- package/src/definitions/models/whisper.ts +44 -0
- package/src/definitions/skills/index.ts +12 -0
- package/src/definitions/skills/talking-character.ts +87 -0
- package/src/definitions/skills/text-to-tiktok.ts +97 -0
- package/src/index.ts +118 -0
- package/src/providers/apify.ts +269 -0
- package/src/providers/base.ts +264 -0
- package/src/providers/elevenlabs.ts +217 -0
- package/src/providers/fal.ts +392 -0
- package/src/providers/ffmpeg.ts +544 -0
- package/src/providers/fireworks.ts +193 -0
- package/src/providers/groq.ts +149 -0
- package/src/providers/higgsfield.ts +145 -0
- package/src/providers/index.ts +143 -0
- package/src/providers/replicate.ts +147 -0
- package/src/providers/storage.ts +206 -0
- package/src/react/cli.ts +52 -0
- package/src/react/elements.ts +146 -0
- package/src/react/examples/branching.tsx +66 -0
- package/src/react/examples/captions-demo.tsx +37 -0
- package/src/react/examples/character-video.tsx +84 -0
- package/src/react/examples/grid.tsx +53 -0
- package/src/react/examples/layouts-demo.tsx +57 -0
- package/src/react/examples/madi.tsx +60 -0
- package/src/react/examples/music-test.tsx +35 -0
- package/src/react/examples/onlyfans-1m/workflow.tsx +88 -0
- package/src/react/examples/orange-portrait.tsx +41 -0
- package/src/react/examples/split-element-demo.tsx +60 -0
- package/src/react/examples/split-layout-demo.tsx +60 -0
- package/src/react/examples/split.tsx +41 -0
- package/src/react/examples/video-grid.tsx +46 -0
- package/src/react/index.ts +43 -0
- package/src/react/layouts/grid.tsx +28 -0
- package/src/react/layouts/index.ts +2 -0
- package/src/react/layouts/split.tsx +20 -0
- package/src/react/react.test.ts +309 -0
- package/src/react/render.ts +21 -0
- package/src/react/renderers/animate.ts +59 -0
- package/src/react/renderers/captions.ts +297 -0
- package/src/react/renderers/clip.ts +248 -0
- package/src/react/renderers/context.ts +17 -0
- package/src/react/renderers/image.ts +109 -0
- package/src/react/renderers/index.ts +22 -0
- package/src/react/renderers/music.ts +60 -0
- package/src/react/renderers/packshot.ts +84 -0
- package/src/react/renderers/progress.ts +173 -0
- package/src/react/renderers/render.ts +243 -0
- package/src/react/renderers/slider.ts +69 -0
- package/src/react/renderers/speech.ts +53 -0
- package/src/react/renderers/split.ts +91 -0
- package/src/react/renderers/subtitle.ts +16 -0
- package/src/react/renderers/swipe.ts +75 -0
- package/src/react/renderers/title.ts +17 -0
- package/src/react/renderers/utils.ts +124 -0
- package/src/react/renderers/video.ts +127 -0
- package/src/react/runtime/jsx-dev-runtime.ts +43 -0
- package/src/react/runtime/jsx-runtime.ts +35 -0
- package/src/react/types.ts +232 -0
- package/src/studio/index.ts +26 -0
- package/src/studio/scanner.ts +102 -0
- package/src/studio/server.ts +554 -0
- package/src/studio/stages.ts +251 -0
- package/src/studio/step-renderer.ts +279 -0
- package/src/studio/types.ts +60 -0
- package/src/studio/ui/cache.html +303 -0
- package/src/studio/ui/index.html +1820 -0
- package/src/tests/all.test.ts +509 -0
- package/src/tests/index.ts +33 -0
- package/src/tests/unit.test.ts +403 -0
- package/tsconfig.cli.json +8 -0
- package/tsconfig.json +21 -3
- package/TEST_RESULTS.md +0 -122
- package/action/captions/SKILL.md +0 -170
- package/action/captions/index.ts +0 -169
- package/action/edit/SKILL.md +0 -235
- package/action/edit/index.ts +0 -437
- package/action/image/SKILL.md +0 -140
- package/action/image/index.ts +0 -105
- package/action/sync/SKILL.md +0 -136
- package/action/sync/index.ts +0 -145
- package/action/transcribe/SKILL.md +0 -179
- package/action/video/SKILL.md +0 -116
- package/action/video/index.ts +0 -125
- package/action/voice/SKILL.md +0 -125
- package/action/voice/index.ts +0 -136
- package/cli/commands/find.ts +0 -58
- package/cli/commands/help.ts +0 -70
- package/cli/commands/list.ts +0 -49
- package/cli/commands/run.ts +0 -237
- package/cli/commands/which.ts +0 -66
- package/cli/discover.ts +0 -66
- package/cli/index.ts +0 -33
- package/cli/runner.ts +0 -65
- package/cli/types.ts +0 -49
- package/cli/ui.ts +0 -185
- package/index.ts +0 -75
- package/lib/README.md +0 -144
- package/lib/ai-sdk/fal.ts +0 -106
- package/lib/ai-sdk/replicate.ts +0 -107
- package/lib/elevenlabs.ts +0 -382
- package/lib/fal.ts +0 -467
- package/lib/ffmpeg.ts +0 -467
- package/lib/fireworks.ts +0 -235
- package/lib/groq.ts +0 -246
- package/lib/higgsfield.ts +0 -176
- package/lib/remotion/SKILL.md +0 -823
- package/lib/remotion/cli.ts +0 -115
- package/lib/remotion/functions.ts +0 -283
- package/lib/remotion/index.ts +0 -19
- package/lib/remotion/templates.ts +0 -73
- package/lib/replicate.ts +0 -304
- package/output.txt +0 -1
- package/test-import.ts +0 -7
- package/test-services.ts +0 -97
- package/utilities/s3.ts +0 -147
package/action/captions/SKILL.md
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: video-captions
|
|
3
|
-
description: add auto-generated or custom subtitles to videos using groq/fireworks transcription and ffmpeg overlay. use when adding captions, subtitles, or text overlays to videos for accessibility or social media.
|
|
4
|
-
allowed-tools: Read, Bash
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# video captions
|
|
8
|
-
|
|
9
|
-
automatically generate and overlay subtitles on videos with customizable styling.
|
|
10
|
-
|
|
11
|
-
## features
|
|
12
|
-
|
|
13
|
-
- **auto-generation**: transcribe video audio using groq or fireworks
|
|
14
|
-
- **custom srt support**: use existing subtitle files
|
|
15
|
-
- **styling**: customize font, size, colors, position
|
|
16
|
-
- **word-level timing**: fireworks provides precise word timestamps
|
|
17
|
-
- **instant overlay**: ffmpeg-based subtitle rendering
|
|
18
|
-
|
|
19
|
-
## usage
|
|
20
|
-
|
|
21
|
-
### auto-generate captions
|
|
22
|
-
```bash
|
|
23
|
-
bun run service/captions.ts <videoPath> [outputPath] [options]
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**basic example:**
|
|
27
|
-
```bash
|
|
28
|
-
bun run service/captions.ts media/video.mp4
|
|
29
|
-
# outputs: media/video-captioned.mp4
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**with options:**
|
|
33
|
-
```bash
|
|
34
|
-
bun run service/captions.ts media/video.mp4 output.mp4 --provider fireworks --font Arial --size 28
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### use existing srt file
|
|
38
|
-
```bash
|
|
39
|
-
bun run service/captions.ts media/video.mp4 output.mp4 --srt media/video.srt
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## options
|
|
43
|
-
|
|
44
|
-
- `--srt <path>` - use existing srt file instead of auto-generating
|
|
45
|
-
- `--provider <name>` - groq or fireworks (default: fireworks)
|
|
46
|
-
- `--font <name>` - font name (default: Arial)
|
|
47
|
-
- `--size <number>` - font size (default: 24)
|
|
48
|
-
- `--color <hex>` - primary color in ASS format (default: &HFFFFFF white)
|
|
49
|
-
- `--outline <hex>` - outline color in ASS format (default: &H000000 black)
|
|
50
|
-
|
|
51
|
-
## as library
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
import { addCaptions } from "./service/captions"
|
|
55
|
-
|
|
56
|
-
const result = await addCaptions({
|
|
57
|
-
videoPath: "media/video.mp4",
|
|
58
|
-
output: "captioned.mp4",
|
|
59
|
-
provider: "fireworks", // or "groq"
|
|
60
|
-
style: {
|
|
61
|
-
fontName: "Helvetica",
|
|
62
|
-
fontSize: 28,
|
|
63
|
-
primaryColor: "&HFFFFFF",
|
|
64
|
-
outlineColor: "&H000000",
|
|
65
|
-
bold: true,
|
|
66
|
-
alignment: 2, // bottom center
|
|
67
|
-
marginV: 20
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## providers
|
|
73
|
-
|
|
74
|
-
### fireworks (recommended)
|
|
75
|
-
- **word-level timestamps** for precise timing
|
|
76
|
-
- generates `.srt` format with detailed timing
|
|
77
|
-
- better for social media content
|
|
78
|
-
- slightly slower transcription
|
|
79
|
-
|
|
80
|
-
### groq
|
|
81
|
-
- **ultra-fast** transcription
|
|
82
|
-
- plain text output (converted to srt)
|
|
83
|
-
- sentence-level timing
|
|
84
|
-
- great for quick previews
|
|
85
|
-
|
|
86
|
-
## styling options
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
interface SubtitleStyle {
|
|
90
|
-
fontName?: string // default: Arial
|
|
91
|
-
fontSize?: number // default: 24
|
|
92
|
-
primaryColor?: string // default: &HFFFFFF (white)
|
|
93
|
-
outlineColor?: string // default: &H000000 (black)
|
|
94
|
-
bold?: boolean // default: true
|
|
95
|
-
alignment?: number // 1-9, default: 2 (bottom center)
|
|
96
|
-
marginV?: number // vertical margin, default: 20
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**alignment values:**
|
|
101
|
-
```
|
|
102
|
-
1 = bottom left 2 = bottom center 3 = bottom right
|
|
103
|
-
4 = middle left 5 = middle center 6 = middle right
|
|
104
|
-
7 = top left 8 = top center 9 = top right
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## when to use
|
|
108
|
-
|
|
109
|
-
use this skill when:
|
|
110
|
-
- preparing videos for social media (tiktok, instagram, youtube)
|
|
111
|
-
- adding accessibility features
|
|
112
|
-
- creating educational or tutorial content
|
|
113
|
-
- need word-level caption timing
|
|
114
|
-
- translating videos with custom srt files
|
|
115
|
-
|
|
116
|
-
## typical workflow
|
|
117
|
-
|
|
118
|
-
1. create or edit video
|
|
119
|
-
2. add captions with auto-transcription (this service)
|
|
120
|
-
3. customize style for platform
|
|
121
|
-
4. prepare for social media (edit service)
|
|
122
|
-
|
|
123
|
-
## examples
|
|
124
|
-
|
|
125
|
-
**tiktok/instagram style captions:**
|
|
126
|
-
```bash
|
|
127
|
-
bun run service/captions.ts video.mp4 captioned.mp4 \
|
|
128
|
-
--provider fireworks \
|
|
129
|
-
--font "Arial Black" \
|
|
130
|
-
--size 32 \
|
|
131
|
-
--color "&H00FFFF"
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**professional style:**
|
|
135
|
-
```bash
|
|
136
|
-
bun run service/captions.ts video.mp4 output.mp4 \
|
|
137
|
-
--provider fireworks \
|
|
138
|
-
--font "Helvetica" \
|
|
139
|
-
--size 24
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**with existing subtitles:**
|
|
143
|
-
```bash
|
|
144
|
-
bun run service/captions.ts video.mp4 final.mp4 \
|
|
145
|
-
--srt custom-subtitles.srt \
|
|
146
|
-
--font "Arial" \
|
|
147
|
-
--size 26
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## output
|
|
151
|
-
|
|
152
|
-
- generates `.srt` file if auto-transcribing
|
|
153
|
-
- creates new video file with burned-in subtitles
|
|
154
|
-
- preserves original video quality
|
|
155
|
-
- audio is copied without re-encoding
|
|
156
|
-
|
|
157
|
-
## environment variables
|
|
158
|
-
|
|
159
|
-
required (for auto-transcription):
|
|
160
|
-
- `GROQ_API_KEY` - for groq provider
|
|
161
|
-
- `FIREWORKS_API_KEY` - for fireworks provider
|
|
162
|
-
|
|
163
|
-
**system requirements:**
|
|
164
|
-
- ffmpeg must be installed
|
|
165
|
-
|
|
166
|
-
## processing time
|
|
167
|
-
|
|
168
|
-
- transcription: 5-30 seconds (depending on video length)
|
|
169
|
-
- overlay: 5-15 seconds (depending on video length)
|
|
170
|
-
- total: typically under 1 minute
|
package/action/captions/index.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* video captioning service
|
|
5
|
-
* generates and overlays subtitles on videos using ffmpeg
|
|
6
|
-
* supports auto-generation via groq/fireworks or custom srt files
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { existsSync } from "node:fs";
|
|
10
|
-
import ffmpeg from "fluent-ffmpeg";
|
|
11
|
-
import type { ActionMeta } from "../../cli/types";
|
|
12
|
-
import { transcribe } from "../transcribe";
|
|
13
|
-
|
|
14
|
-
export const meta: ActionMeta = {
|
|
15
|
-
name: "captions",
|
|
16
|
-
type: "action",
|
|
17
|
-
description: "add subtitles to video",
|
|
18
|
-
inputType: "video",
|
|
19
|
-
outputType: "video",
|
|
20
|
-
schema: {
|
|
21
|
-
input: {
|
|
22
|
-
type: "object",
|
|
23
|
-
required: ["video", "output"],
|
|
24
|
-
properties: {
|
|
25
|
-
video: {
|
|
26
|
-
type: "string",
|
|
27
|
-
format: "file-path",
|
|
28
|
-
description: "input video file",
|
|
29
|
-
},
|
|
30
|
-
output: {
|
|
31
|
-
type: "string",
|
|
32
|
-
format: "file-path",
|
|
33
|
-
description: "output video path",
|
|
34
|
-
},
|
|
35
|
-
srt: {
|
|
36
|
-
type: "string",
|
|
37
|
-
format: "file-path",
|
|
38
|
-
description: "existing srt file (auto-generates if not provided)",
|
|
39
|
-
},
|
|
40
|
-
provider: {
|
|
41
|
-
type: "string",
|
|
42
|
-
enum: ["groq", "fireworks"],
|
|
43
|
-
default: "fireworks",
|
|
44
|
-
description: "transcription provider for auto-generation",
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
output: { type: "string", format: "file-path", description: "video path" },
|
|
49
|
-
},
|
|
50
|
-
async run(options) {
|
|
51
|
-
const { video, output, srt, provider } = options as {
|
|
52
|
-
video: string;
|
|
53
|
-
output: string;
|
|
54
|
-
srt?: string;
|
|
55
|
-
provider?: "groq" | "fireworks";
|
|
56
|
-
};
|
|
57
|
-
return addCaptions({ videoPath: video, output, srtPath: srt, provider });
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// types
|
|
62
|
-
export interface AddCaptionsOptions {
|
|
63
|
-
videoPath: string;
|
|
64
|
-
srtPath?: string; // optional existing srt file
|
|
65
|
-
output: string;
|
|
66
|
-
provider?: "groq" | "fireworks"; // only used if srtPath not provided
|
|
67
|
-
style?: SubtitleStyle;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface SubtitleStyle {
|
|
71
|
-
fontName?: string; // default: Arial
|
|
72
|
-
fontSize?: number; // default: 24
|
|
73
|
-
primaryColor?: string; // default: &HFFFFFF (white)
|
|
74
|
-
outlineColor?: string; // default: &H000000 (black)
|
|
75
|
-
bold?: boolean; // default: true
|
|
76
|
-
alignment?: number; // 1-9, default: 2 (bottom center)
|
|
77
|
-
marginV?: number; // vertical margin, default: 20
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// default subtitle style
|
|
81
|
-
const DEFAULT_STYLE: Required<SubtitleStyle> = {
|
|
82
|
-
fontName: "Arial",
|
|
83
|
-
fontSize: 24,
|
|
84
|
-
primaryColor: "&HFFFFFF", // white
|
|
85
|
-
outlineColor: "&H000000", // black
|
|
86
|
-
bold: true,
|
|
87
|
-
alignment: 2, // bottom center
|
|
88
|
-
marginV: 20,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// main function to add captions to video
|
|
92
|
-
export async function addCaptions(
|
|
93
|
-
options: AddCaptionsOptions,
|
|
94
|
-
): Promise<string> {
|
|
95
|
-
const { videoPath, srtPath, output, provider = "fireworks", style } = options;
|
|
96
|
-
|
|
97
|
-
if (!videoPath) {
|
|
98
|
-
throw new Error("videoPath is required");
|
|
99
|
-
}
|
|
100
|
-
if (!output) {
|
|
101
|
-
throw new Error("output is required");
|
|
102
|
-
}
|
|
103
|
-
if (!existsSync(videoPath)) {
|
|
104
|
-
throw new Error(`video file not found: ${videoPath}`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
console.log("[captions] adding captions to video...");
|
|
108
|
-
|
|
109
|
-
// determine srt file path
|
|
110
|
-
let finalSrtPath = srtPath;
|
|
111
|
-
|
|
112
|
-
// if no srt file provided, auto-generate it
|
|
113
|
-
if (!finalSrtPath) {
|
|
114
|
-
console.log(
|
|
115
|
-
`[captions] no srt file provided, auto-generating with ${provider}...`,
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
// generate srt file from video audio
|
|
119
|
-
const tempSrtPath = videoPath.replace(/\.[^.]+$/, ".srt");
|
|
120
|
-
|
|
121
|
-
const result = await transcribe({
|
|
122
|
-
audioUrl: videoPath,
|
|
123
|
-
provider,
|
|
124
|
-
outputFormat: "srt",
|
|
125
|
-
outputPath: tempSrtPath,
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
if (!result.success) {
|
|
129
|
-
throw new Error(`failed to generate subtitles: ${result.error}`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
finalSrtPath = tempSrtPath;
|
|
133
|
-
console.log(`[captions] generated subtitles at ${finalSrtPath}`);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (!existsSync(finalSrtPath)) {
|
|
137
|
-
throw new Error(`srt file not found: ${finalSrtPath}`);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// merge style with defaults
|
|
141
|
-
const finalStyle = { ...DEFAULT_STYLE, ...style };
|
|
142
|
-
|
|
143
|
-
// build subtitle filter with style
|
|
144
|
-
const subtitlesFilter = `subtitles=${finalSrtPath}:force_style='FontName=${finalStyle.fontName},FontSize=${finalStyle.fontSize},PrimaryColour=${finalStyle.primaryColor},OutlineColour=${finalStyle.outlineColor},Bold=${finalStyle.bold ? -1 : 0},Alignment=${finalStyle.alignment},MarginV=${finalStyle.marginV}'`;
|
|
145
|
-
|
|
146
|
-
console.log("[captions] overlaying subtitles on video...");
|
|
147
|
-
|
|
148
|
-
return new Promise((resolve, reject) => {
|
|
149
|
-
ffmpeg(videoPath)
|
|
150
|
-
.videoFilters(subtitlesFilter)
|
|
151
|
-
.outputOptions(["-c:a", "copy"]) // copy audio without re-encoding
|
|
152
|
-
.output(output)
|
|
153
|
-
.on("end", () => {
|
|
154
|
-
console.log(`[captions] saved to ${output}`);
|
|
155
|
-
resolve(output);
|
|
156
|
-
})
|
|
157
|
-
.on("error", (err) => {
|
|
158
|
-
console.error("[captions] error:", err);
|
|
159
|
-
reject(err);
|
|
160
|
-
})
|
|
161
|
-
.run();
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// cli
|
|
166
|
-
if (import.meta.main) {
|
|
167
|
-
const { runCli } = await import("../../cli/runner");
|
|
168
|
-
runCli(meta);
|
|
169
|
-
}
|
package/action/edit/SKILL.md
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: video-editing
|
|
3
|
-
description: edit videos with ffmpeg operations including resize, trim, concat, social media optimization, and montage creation. use for video editing, format conversion, social media prep, merging clips, or batch video operations.
|
|
4
|
-
allowed-tools: Read, Bash
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# video editing
|
|
8
|
-
|
|
9
|
-
comprehensive video editing service combining ffmpeg operations into common workflows.
|
|
10
|
-
|
|
11
|
-
## commands
|
|
12
|
-
|
|
13
|
-
### prepare for social media
|
|
14
|
-
```bash
|
|
15
|
-
bun run service/edit.ts social <input> <output> <platform> [audioPath]
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
automatically resize and optimize for platform specs:
|
|
19
|
-
- **tiktok**: 1080x1920 (9:16)
|
|
20
|
-
- **instagram**: 1080x1920 (9:16)
|
|
21
|
-
- **youtube-shorts**: 1080x1920 (9:16)
|
|
22
|
-
- **youtube**: 1920x1080 (16:9)
|
|
23
|
-
- **twitter**: 1280x720 (16:9)
|
|
24
|
-
|
|
25
|
-
**example:**
|
|
26
|
-
```bash
|
|
27
|
-
bun run service/edit.ts social raw.mp4 tiktok.mp4 tiktok
|
|
28
|
-
bun run service/edit.ts social raw.mp4 ig.mp4 instagram audio.mp3
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### create montage
|
|
32
|
-
```bash
|
|
33
|
-
bun run service/edit.ts montage <output> <clip1> <clip2> [clip3...]
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
combine multiple video clips into one:
|
|
37
|
-
|
|
38
|
-
**example:**
|
|
39
|
-
```bash
|
|
40
|
-
bun run service/edit.ts montage final.mp4 intro.mp4 main.mp4 outro.mp4
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### quick trim
|
|
44
|
-
```bash
|
|
45
|
-
bun run service/edit.ts trim <input> <output> <start> [end]
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
extract a segment from video:
|
|
49
|
-
|
|
50
|
-
**example:**
|
|
51
|
-
```bash
|
|
52
|
-
bun run service/edit.ts trim long.mp4 short.mp4 10 30
|
|
53
|
-
# extracts seconds 10-30
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### quick resize
|
|
57
|
-
```bash
|
|
58
|
-
bun run service/edit.ts resize <input> <output> <preset>
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
resize to common aspect ratios:
|
|
62
|
-
- **vertical**: 9:16 (1080x1920)
|
|
63
|
-
- **square**: 1:1 (1080x1080)
|
|
64
|
-
- **landscape**: 16:9 (1920x1080)
|
|
65
|
-
- **4k**: 3840x2160
|
|
66
|
-
|
|
67
|
-
**example:**
|
|
68
|
-
```bash
|
|
69
|
-
bun run service/edit.ts resize raw.mp4 vertical.mp4 vertical
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### merge with audio
|
|
73
|
-
```bash
|
|
74
|
-
bun run service/edit.ts merge_audio <audio> <output> <video1> [video2...]
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
concatenate videos and add audio overlay:
|
|
78
|
-
|
|
79
|
-
**example:**
|
|
80
|
-
```bash
|
|
81
|
-
bun run service/edit.ts merge_audio song.mp3 final.mp4 clip1.mp4 clip2.mp4
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## as library
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
import {
|
|
88
|
-
prepareForSocial,
|
|
89
|
-
createMontage,
|
|
90
|
-
quickTrim,
|
|
91
|
-
quickResize,
|
|
92
|
-
mergeWithAudio,
|
|
93
|
-
editPipeline
|
|
94
|
-
} from "./service/edit"
|
|
95
|
-
|
|
96
|
-
// social media optimization
|
|
97
|
-
await prepareForSocial({
|
|
98
|
-
input: "raw.mp4",
|
|
99
|
-
output: "tiktok.mp4",
|
|
100
|
-
platform: "tiktok",
|
|
101
|
-
withAudio: "audio.mp3"
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
// create montage
|
|
105
|
-
await createMontage({
|
|
106
|
-
clips: ["clip1.mp4", "clip2.mp4"],
|
|
107
|
-
output: "montage.mp4",
|
|
108
|
-
maxClipDuration: 5,
|
|
109
|
-
targetResolution: { width: 1920, height: 1080 }
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
// trim video
|
|
113
|
-
await quickTrim("video.mp4", "trimmed.mp4", 10, 30)
|
|
114
|
-
|
|
115
|
-
// resize video
|
|
116
|
-
await quickResize("video.mp4", "resized.mp4", "vertical")
|
|
117
|
-
|
|
118
|
-
// merge videos with audio
|
|
119
|
-
await mergeWithAudio(
|
|
120
|
-
["clip1.mp4", "clip2.mp4"],
|
|
121
|
-
"audio.mp3",
|
|
122
|
-
"final.mp4"
|
|
123
|
-
)
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## advanced: edit pipeline
|
|
127
|
-
|
|
128
|
-
chain multiple operations:
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
import { editPipeline } from "./service/edit"
|
|
132
|
-
|
|
133
|
-
await editPipeline({
|
|
134
|
-
steps: [
|
|
135
|
-
{
|
|
136
|
-
operation: "resize",
|
|
137
|
-
options: {
|
|
138
|
-
input: "raw.mp4",
|
|
139
|
-
width: 1080,
|
|
140
|
-
height: 1920
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
operation: "add_audio",
|
|
145
|
-
options: {
|
|
146
|
-
videoPath: "temp.mp4",
|
|
147
|
-
audioPath: "music.mp3"
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
operation: "trim",
|
|
152
|
-
options: {
|
|
153
|
-
input: "temp2.mp4",
|
|
154
|
-
start: 0,
|
|
155
|
-
duration: 30
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
],
|
|
159
|
-
finalOutput: "final.mp4"
|
|
160
|
-
})
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
**available operations:**
|
|
164
|
-
- `concat` - concatenate videos
|
|
165
|
-
- `add_audio` - overlay audio
|
|
166
|
-
- `resize` - change dimensions
|
|
167
|
-
- `trim` - extract segment
|
|
168
|
-
- `convert` - change format
|
|
169
|
-
- `extract_audio` - extract audio track
|
|
170
|
-
|
|
171
|
-
## when to use
|
|
172
|
-
|
|
173
|
-
use this skill when:
|
|
174
|
-
- preparing videos for social media platforms
|
|
175
|
-
- combining multiple video clips
|
|
176
|
-
- extracting segments from longer videos
|
|
177
|
-
- resizing to specific aspect ratios
|
|
178
|
-
- adding background music to video montages
|
|
179
|
-
- batch processing video files
|
|
180
|
-
- optimizing videos for specific platforms
|
|
181
|
-
|
|
182
|
-
## typical workflows
|
|
183
|
-
|
|
184
|
-
### social media content
|
|
185
|
-
1. create or edit raw video
|
|
186
|
-
2. add captions (captions service)
|
|
187
|
-
3. prepare for platform (this service)
|
|
188
|
-
4. upload
|
|
189
|
-
|
|
190
|
-
### video montage
|
|
191
|
-
1. collect multiple clips
|
|
192
|
-
2. create montage (this service)
|
|
193
|
-
3. add audio overlay (this service)
|
|
194
|
-
4. add captions if needed (captions service)
|
|
195
|
-
|
|
196
|
-
### talking character for social
|
|
197
|
-
1. generate character (image service)
|
|
198
|
-
2. animate (video service)
|
|
199
|
-
3. sync with voice (sync service)
|
|
200
|
-
4. add captions (captions service)
|
|
201
|
-
5. optimize for tiktok/instagram (this service)
|
|
202
|
-
|
|
203
|
-
## tips
|
|
204
|
-
|
|
205
|
-
**social media optimization:**
|
|
206
|
-
- use platform-specific presets for correct aspect ratio
|
|
207
|
-
- vertical format (9:16) works for tiktok, instagram reels, youtube shorts
|
|
208
|
-
- landscape (16:9) works for youtube, twitter
|
|
209
|
-
|
|
210
|
-
**montage creation:**
|
|
211
|
-
- all clips should have similar resolution for best results
|
|
212
|
-
- use `maxClipDuration` to keep montage paced
|
|
213
|
-
- `targetResolution` ensures consistent quality
|
|
214
|
-
|
|
215
|
-
**trimming:**
|
|
216
|
-
- start time is in seconds
|
|
217
|
-
- end time is optional (omit to trim to end of video)
|
|
218
|
-
- use for extracting highlights or removing unwanted sections
|
|
219
|
-
|
|
220
|
-
## environment variables
|
|
221
|
-
|
|
222
|
-
no api keys required - uses ffmpeg
|
|
223
|
-
|
|
224
|
-
**system requirements:**
|
|
225
|
-
- ffmpeg must be installed
|
|
226
|
-
- `brew install ffmpeg` (macos)
|
|
227
|
-
- `apt-get install ffmpeg` (linux)
|
|
228
|
-
|
|
229
|
-
## processing time
|
|
230
|
-
|
|
231
|
-
depends on operation and video size:
|
|
232
|
-
- trim: 5-10 seconds
|
|
233
|
-
- resize: 10-30 seconds
|
|
234
|
-
- concat: 10-30 seconds per clip
|
|
235
|
-
- social optimization: 15-45 seconds
|