varg.ai-sdk 0.1.0 → 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.
Files changed (236) hide show
  1. package/.claude/settings.local.json +1 -1
  2. package/.env.example +3 -0
  3. package/.github/workflows/ci.yml +23 -0
  4. package/.husky/README.md +102 -0
  5. package/.husky/commit-msg +6 -0
  6. package/.husky/pre-commit +9 -0
  7. package/.husky/pre-push +6 -0
  8. package/.size-limit.json +8 -0
  9. package/.test-hooks.ts +5 -0
  10. package/CLAUDE.md +10 -3
  11. package/CONTRIBUTING.md +150 -0
  12. package/LICENSE.md +53 -0
  13. package/README.md +56 -209
  14. package/SKILLS.md +26 -10
  15. package/biome.json +7 -1
  16. package/bun.lock +1286 -0
  17. package/commitlint.config.js +22 -0
  18. package/docs/index.html +1130 -0
  19. package/docs/prompting.md +326 -0
  20. package/docs/react.md +834 -0
  21. package/docs/sdk.md +812 -0
  22. package/ffmpeg/CLAUDE.md +68 -0
  23. package/package.json +48 -8
  24. package/pipeline/cookbooks/scripts/animate-frames-parallel.ts +84 -0
  25. package/pipeline/cookbooks/scripts/combine-scenes.sh +53 -0
  26. package/pipeline/cookbooks/scripts/generate-frames-parallel.ts +99 -0
  27. package/pipeline/cookbooks/scripts/still-to-video.sh +37 -0
  28. package/pipeline/cookbooks/text-to-tiktok.md +669 -0
  29. package/pipeline/cookbooks/trendwatching.md +156 -0
  30. package/plan.md +281 -0
  31. package/scripts/.gitkeep +0 -0
  32. package/src/ai-sdk/cache.ts +142 -0
  33. package/src/ai-sdk/examples/cached-generation.ts +53 -0
  34. package/src/ai-sdk/examples/duet-scene-4.ts +53 -0
  35. package/src/ai-sdk/examples/duet-scene-5-audio.ts +32 -0
  36. package/src/ai-sdk/examples/duet-video.ts +56 -0
  37. package/src/ai-sdk/examples/editly-composition.ts +63 -0
  38. package/src/ai-sdk/examples/editly-test.ts +57 -0
  39. package/src/ai-sdk/examples/editly-video-test.ts +52 -0
  40. package/src/ai-sdk/examples/fal-lipsync.ts +43 -0
  41. package/src/ai-sdk/examples/higgsfield-image.ts +61 -0
  42. package/src/ai-sdk/examples/music-generation.ts +19 -0
  43. package/src/ai-sdk/examples/openai-sora.ts +34 -0
  44. package/src/ai-sdk/examples/replicate-bg-removal.ts +52 -0
  45. package/src/ai-sdk/examples/simpsons-scene.ts +61 -0
  46. package/src/ai-sdk/examples/talking-lion.ts +55 -0
  47. package/src/ai-sdk/examples/video-generation.ts +39 -0
  48. package/src/ai-sdk/examples/workflow-animated-girl.ts +104 -0
  49. package/src/ai-sdk/examples/workflow-before-after.ts +114 -0
  50. package/src/ai-sdk/examples/workflow-character-grid.ts +112 -0
  51. package/src/ai-sdk/examples/workflow-slideshow.ts +161 -0
  52. package/src/ai-sdk/file-cache.ts +112 -0
  53. package/src/ai-sdk/file.ts +238 -0
  54. package/src/ai-sdk/generate-element.ts +92 -0
  55. package/src/ai-sdk/generate-music.ts +46 -0
  56. package/src/ai-sdk/generate-video.ts +165 -0
  57. package/src/ai-sdk/index.ts +72 -0
  58. package/src/ai-sdk/music-model.ts +110 -0
  59. package/src/ai-sdk/providers/editly/editly.test.ts +1108 -0
  60. package/src/ai-sdk/providers/editly/ffmpeg.ts +60 -0
  61. package/src/ai-sdk/providers/editly/index.ts +817 -0
  62. package/src/ai-sdk/providers/editly/layers.ts +776 -0
  63. package/src/ai-sdk/providers/editly/plan.md +144 -0
  64. package/src/ai-sdk/providers/editly/types.ts +328 -0
  65. package/src/ai-sdk/providers/elevenlabs-provider.ts +255 -0
  66. package/src/ai-sdk/providers/fal-provider.ts +512 -0
  67. package/src/ai-sdk/providers/higgsfield.ts +379 -0
  68. package/src/ai-sdk/providers/openai.ts +251 -0
  69. package/src/ai-sdk/providers/replicate.ts +16 -0
  70. package/src/ai-sdk/video-model.ts +185 -0
  71. package/src/cli/commands/find.tsx +137 -0
  72. package/src/cli/commands/help.tsx +85 -0
  73. package/src/cli/commands/index.ts +6 -0
  74. package/src/cli/commands/list.tsx +238 -0
  75. package/src/cli/commands/render.tsx +71 -0
  76. package/src/cli/commands/run.tsx +511 -0
  77. package/src/cli/commands/which.tsx +253 -0
  78. package/src/cli/index.ts +114 -0
  79. package/src/cli/quiet.ts +44 -0
  80. package/src/cli/types.ts +32 -0
  81. package/src/cli/ui/components/Badge.tsx +29 -0
  82. package/src/cli/ui/components/DataTable.tsx +51 -0
  83. package/src/cli/ui/components/Header.tsx +23 -0
  84. package/src/cli/ui/components/HelpBlock.tsx +44 -0
  85. package/src/cli/ui/components/KeyValue.tsx +33 -0
  86. package/src/cli/ui/components/OptionRow.tsx +81 -0
  87. package/src/cli/ui/components/Separator.tsx +23 -0
  88. package/src/cli/ui/components/StatusBox.tsx +108 -0
  89. package/src/cli/ui/components/VargBox.tsx +51 -0
  90. package/src/cli/ui/components/VargProgress.tsx +36 -0
  91. package/src/cli/ui/components/VargSpinner.tsx +34 -0
  92. package/src/cli/ui/components/VargText.tsx +56 -0
  93. package/src/cli/ui/components/index.ts +19 -0
  94. package/src/cli/ui/index.ts +12 -0
  95. package/src/cli/ui/render.ts +35 -0
  96. package/src/cli/ui/theme.ts +63 -0
  97. package/src/cli/utils.ts +78 -0
  98. package/src/core/executor/executor.ts +201 -0
  99. package/src/core/executor/index.ts +13 -0
  100. package/src/core/executor/job.ts +214 -0
  101. package/src/core/executor/pipeline.ts +222 -0
  102. package/src/core/index.ts +11 -0
  103. package/src/core/registry/index.ts +9 -0
  104. package/src/core/registry/loader.ts +149 -0
  105. package/src/core/registry/registry.ts +221 -0
  106. package/src/core/registry/resolver.ts +206 -0
  107. package/src/core/schema/helpers.ts +134 -0
  108. package/src/core/schema/index.ts +8 -0
  109. package/src/core/schema/shared.ts +102 -0
  110. package/src/core/schema/types.ts +279 -0
  111. package/src/core/schema/validator.ts +92 -0
  112. package/src/definitions/actions/captions.ts +261 -0
  113. package/src/definitions/actions/edit.ts +298 -0
  114. package/src/definitions/actions/image.ts +125 -0
  115. package/src/definitions/actions/index.ts +114 -0
  116. package/src/definitions/actions/music.ts +205 -0
  117. package/src/definitions/actions/sync.ts +128 -0
  118. package/{action/transcribe/index.ts → src/definitions/actions/transcribe.ts} +63 -90
  119. package/src/definitions/actions/upload.ts +111 -0
  120. package/src/definitions/actions/video.ts +163 -0
  121. package/src/definitions/actions/voice.ts +119 -0
  122. package/src/definitions/index.ts +23 -0
  123. package/src/definitions/models/elevenlabs.ts +50 -0
  124. package/src/definitions/models/flux.ts +56 -0
  125. package/src/definitions/models/index.ts +36 -0
  126. package/src/definitions/models/kling.ts +56 -0
  127. package/src/definitions/models/llama.ts +54 -0
  128. package/src/definitions/models/nano-banana-pro.ts +102 -0
  129. package/src/definitions/models/sonauto.ts +68 -0
  130. package/src/definitions/models/soul.ts +65 -0
  131. package/src/definitions/models/wan.ts +54 -0
  132. package/src/definitions/models/whisper.ts +44 -0
  133. package/src/definitions/skills/index.ts +12 -0
  134. package/src/definitions/skills/talking-character.ts +87 -0
  135. package/src/definitions/skills/text-to-tiktok.ts +97 -0
  136. package/src/index.ts +118 -0
  137. package/src/providers/apify.ts +269 -0
  138. package/src/providers/base.ts +264 -0
  139. package/src/providers/elevenlabs.ts +217 -0
  140. package/src/providers/fal.ts +392 -0
  141. package/src/providers/ffmpeg.ts +544 -0
  142. package/src/providers/fireworks.ts +193 -0
  143. package/src/providers/groq.ts +149 -0
  144. package/src/providers/higgsfield.ts +145 -0
  145. package/src/providers/index.ts +143 -0
  146. package/src/providers/replicate.ts +147 -0
  147. package/src/providers/storage.ts +206 -0
  148. package/src/react/cli.ts +52 -0
  149. package/src/react/elements.ts +146 -0
  150. package/src/react/examples/branching.tsx +66 -0
  151. package/src/react/examples/captions-demo.tsx +37 -0
  152. package/src/react/examples/character-video.tsx +84 -0
  153. package/src/react/examples/grid.tsx +53 -0
  154. package/src/react/examples/layouts-demo.tsx +57 -0
  155. package/src/react/examples/madi.tsx +60 -0
  156. package/src/react/examples/music-test.tsx +35 -0
  157. package/src/react/examples/onlyfans-1m/workflow.tsx +88 -0
  158. package/src/react/examples/orange-portrait.tsx +41 -0
  159. package/src/react/examples/split-element-demo.tsx +60 -0
  160. package/src/react/examples/split-layout-demo.tsx +60 -0
  161. package/src/react/examples/split.tsx +41 -0
  162. package/src/react/examples/video-grid.tsx +46 -0
  163. package/src/react/index.ts +43 -0
  164. package/src/react/layouts/grid.tsx +28 -0
  165. package/src/react/layouts/index.ts +2 -0
  166. package/src/react/layouts/split.tsx +20 -0
  167. package/src/react/react.test.ts +309 -0
  168. package/src/react/render.ts +21 -0
  169. package/src/react/renderers/animate.ts +59 -0
  170. package/src/react/renderers/captions.ts +297 -0
  171. package/src/react/renderers/clip.ts +248 -0
  172. package/src/react/renderers/context.ts +17 -0
  173. package/src/react/renderers/image.ts +109 -0
  174. package/src/react/renderers/index.ts +22 -0
  175. package/src/react/renderers/music.ts +60 -0
  176. package/src/react/renderers/packshot.ts +84 -0
  177. package/src/react/renderers/progress.ts +173 -0
  178. package/src/react/renderers/render.ts +243 -0
  179. package/src/react/renderers/slider.ts +69 -0
  180. package/src/react/renderers/speech.ts +53 -0
  181. package/src/react/renderers/split.ts +91 -0
  182. package/src/react/renderers/subtitle.ts +16 -0
  183. package/src/react/renderers/swipe.ts +75 -0
  184. package/src/react/renderers/title.ts +17 -0
  185. package/src/react/renderers/utils.ts +124 -0
  186. package/src/react/renderers/video.ts +127 -0
  187. package/src/react/runtime/jsx-dev-runtime.ts +43 -0
  188. package/src/react/runtime/jsx-runtime.ts +35 -0
  189. package/src/react/types.ts +232 -0
  190. package/src/studio/index.ts +26 -0
  191. package/src/studio/scanner.ts +102 -0
  192. package/src/studio/server.ts +554 -0
  193. package/src/studio/stages.ts +251 -0
  194. package/src/studio/step-renderer.ts +279 -0
  195. package/src/studio/types.ts +60 -0
  196. package/src/studio/ui/cache.html +303 -0
  197. package/src/studio/ui/index.html +1820 -0
  198. package/src/tests/all.test.ts +509 -0
  199. package/src/tests/index.ts +33 -0
  200. package/src/tests/unit.test.ts +403 -0
  201. package/tsconfig.cli.json +8 -0
  202. package/tsconfig.json +21 -3
  203. package/TEST_RESULTS.md +0 -122
  204. package/action/captions/SKILL.md +0 -170
  205. package/action/captions/index.ts +0 -227
  206. package/action/edit/SKILL.md +0 -235
  207. package/action/edit/index.ts +0 -493
  208. package/action/image/SKILL.md +0 -140
  209. package/action/image/index.ts +0 -112
  210. package/action/sync/SKILL.md +0 -136
  211. package/action/sync/index.ts +0 -187
  212. package/action/transcribe/SKILL.md +0 -179
  213. package/action/video/SKILL.md +0 -116
  214. package/action/video/index.ts +0 -135
  215. package/action/voice/SKILL.md +0 -125
  216. package/action/voice/index.ts +0 -201
  217. package/index.ts +0 -38
  218. package/lib/README.md +0 -144
  219. package/lib/ai-sdk/fal.ts +0 -106
  220. package/lib/ai-sdk/replicate.ts +0 -107
  221. package/lib/elevenlabs.ts +0 -382
  222. package/lib/fal.ts +0 -478
  223. package/lib/ffmpeg.ts +0 -467
  224. package/lib/fireworks.ts +0 -235
  225. package/lib/groq.ts +0 -246
  226. package/lib/higgsfield.ts +0 -176
  227. package/lib/remotion/SKILL.md +0 -823
  228. package/lib/remotion/cli.ts +0 -115
  229. package/lib/remotion/functions.ts +0 -283
  230. package/lib/remotion/index.ts +0 -19
  231. package/lib/remotion/templates.ts +0 -73
  232. package/lib/replicate.ts +0 -304
  233. package/output.txt +0 -1
  234. package/test-import.ts +0 -7
  235. package/test-services.ts +0 -97
  236. package/utilities/s3.ts +0 -147
@@ -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
@@ -1,227 +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 { transcribe } from "../transcribe";
12
-
13
- // types
14
- export interface AddCaptionsOptions {
15
- videoPath: string;
16
- srtPath?: string; // optional existing srt file
17
- output: string;
18
- provider?: "groq" | "fireworks"; // only used if srtPath not provided
19
- style?: SubtitleStyle;
20
- }
21
-
22
- export interface SubtitleStyle {
23
- fontName?: string; // default: Arial
24
- fontSize?: number; // default: 24
25
- primaryColor?: string; // default: &HFFFFFF (white)
26
- outlineColor?: string; // default: &H000000 (black)
27
- bold?: boolean; // default: true
28
- alignment?: number; // 1-9, default: 2 (bottom center)
29
- marginV?: number; // vertical margin, default: 20
30
- }
31
-
32
- // default subtitle style
33
- const DEFAULT_STYLE: Required<SubtitleStyle> = {
34
- fontName: "Arial",
35
- fontSize: 24,
36
- primaryColor: "&HFFFFFF", // white
37
- outlineColor: "&H000000", // black
38
- bold: true,
39
- alignment: 2, // bottom center
40
- marginV: 20,
41
- };
42
-
43
- // main function to add captions to video
44
- export async function addCaptions(
45
- options: AddCaptionsOptions,
46
- ): Promise<string> {
47
- const { videoPath, srtPath, output, provider = "fireworks", style } = options;
48
-
49
- if (!videoPath) {
50
- throw new Error("videoPath is required");
51
- }
52
- if (!output) {
53
- throw new Error("output is required");
54
- }
55
- if (!existsSync(videoPath)) {
56
- throw new Error(`video file not found: ${videoPath}`);
57
- }
58
-
59
- console.log("[captions] adding captions to video...");
60
-
61
- // determine srt file path
62
- let finalSrtPath = srtPath;
63
-
64
- // if no srt file provided, auto-generate it
65
- if (!finalSrtPath) {
66
- console.log(
67
- `[captions] no srt file provided, auto-generating with ${provider}...`,
68
- );
69
-
70
- // generate srt file from video audio
71
- const tempSrtPath = videoPath.replace(/\.[^.]+$/, ".srt");
72
-
73
- const result = await transcribe({
74
- audioUrl: videoPath,
75
- provider,
76
- outputFormat: "srt",
77
- outputPath: tempSrtPath,
78
- });
79
-
80
- if (!result.success) {
81
- throw new Error(`failed to generate subtitles: ${result.error}`);
82
- }
83
-
84
- finalSrtPath = tempSrtPath;
85
- console.log(`[captions] generated subtitles at ${finalSrtPath}`);
86
- }
87
-
88
- if (!existsSync(finalSrtPath)) {
89
- throw new Error(`srt file not found: ${finalSrtPath}`);
90
- }
91
-
92
- // merge style with defaults
93
- const finalStyle = { ...DEFAULT_STYLE, ...style };
94
-
95
- // build subtitle filter with style
96
- 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}'`;
97
-
98
- console.log("[captions] overlaying subtitles on video...");
99
-
100
- return new Promise((resolve, reject) => {
101
- ffmpeg(videoPath)
102
- .videoFilters(subtitlesFilter)
103
- .outputOptions(["-c:a", "copy"]) // copy audio without re-encoding
104
- .output(output)
105
- .on("end", () => {
106
- console.log(`[captions] saved to ${output}`);
107
- resolve(output);
108
- })
109
- .on("error", (err) => {
110
- console.error("[captions] error:", err);
111
- reject(err);
112
- })
113
- .run();
114
- });
115
- }
116
-
117
- // cli
118
- async function cli() {
119
- const args = process.argv.slice(2);
120
- const command = args[0];
121
-
122
- if (!command || command === "help") {
123
- console.log(`
124
- usage:
125
- bun run service/captions.ts <videoPath> [outputPath] [options]
126
-
127
- arguments:
128
- videoPath - path to input video file
129
- outputPath - path to output video (default: video-captioned.mp4)
130
-
131
- options:
132
- --srt <path> - use existing srt file instead of auto-generating
133
- --provider <name> - groq | fireworks (default: fireworks)
134
- --font <name> - font name (default: Arial)
135
- --size <number> - font size (default: 24)
136
- --color <hex> - primary color in ASS format (default: &HFFFFFF)
137
- --outline <hex> - outline color in ASS format (default: &H000000)
138
-
139
- examples:
140
- # auto-generate captions with fireworks
141
- bun run service/captions.ts media/fitness-demo.mp4
142
-
143
- # auto-generate with groq (faster, plain text)
144
- bun run service/captions.ts media/fitness-demo.mp4 output.mp4 --provider groq
145
-
146
- # use existing srt file
147
- bun run service/captions.ts media/fitness-demo.mp4 output.mp4 --srt media/fitness-demo.srt
148
-
149
- # customize style
150
- bun run service/captions.ts media/video.mp4 output.mp4 --font "Helvetica" --size 28
151
-
152
- requirements:
153
- ffmpeg must be installed on your system
154
- brew install ffmpeg (macos)
155
- apt-get install ffmpeg (linux)
156
- `);
157
- process.exit(0);
158
- }
159
-
160
- try {
161
- const videoPath = args[0];
162
- let outputPath = args[1];
163
-
164
- if (!videoPath) {
165
- throw new Error("videoPath is required");
166
- }
167
-
168
- // parse options
169
- let srtPath: string | undefined;
170
- let provider: "groq" | "fireworks" = "fireworks";
171
- const style: SubtitleStyle = {};
172
-
173
- for (let i = 1; i < args.length; i++) {
174
- const arg = args[i];
175
-
176
- if (arg === "--srt") {
177
- srtPath = args[++i];
178
- } else if (arg === "--provider") {
179
- provider = args[++i] as "groq" | "fireworks";
180
- } else if (arg === "--font") {
181
- style.fontName = args[++i];
182
- } else if (arg === "--size") {
183
- const size = args[++i];
184
- if (!size) {
185
- throw new Error("--size requires a number");
186
- }
187
- style.fontSize = Number.parseInt(size, 10);
188
- } else if (arg === "--color") {
189
- const color = args[++i];
190
- if (!color) {
191
- throw new Error("--color requires a hex color");
192
- }
193
- style.primaryColor = color;
194
- } else if (arg === "--outline") {
195
- const outline = args[++i];
196
- if (!outline) {
197
- throw new Error("--outline requires a hex color");
198
- }
199
- style.outlineColor = outline;
200
- } else if (!arg?.startsWith("--") && !outputPath) {
201
- outputPath = arg;
202
- }
203
- }
204
-
205
- // default output path
206
- if (!outputPath) {
207
- outputPath = videoPath.replace(/\.[^.]+$/, "-captioned.mp4");
208
- }
209
-
210
- await addCaptions({
211
- videoPath,
212
- srtPath,
213
- output: outputPath,
214
- provider,
215
- style,
216
- });
217
-
218
- console.log("\ndone! video with captions saved to:", outputPath);
219
- } catch (error) {
220
- console.error("[captions] error:", error);
221
- process.exit(1);
222
- }
223
- }
224
-
225
- if (import.meta.main) {
226
- cli();
227
- }
@@ -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