@kortix/sandbox 0.4.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/config/customize.sh +143 -0
- package/config/kortix-env-setup.sh +25 -0
- package/kortix-master/package.json +22 -0
- package/kortix-master/src/config.ts +22 -0
- package/kortix-master/src/index.ts +44 -0
- package/kortix-master/src/routes/env.ts +65 -0
- package/kortix-master/src/routes/proxy.ts +108 -0
- package/kortix-master/src/routes/update.ts +185 -0
- package/kortix-master/src/services/proxy.ts +43 -0
- package/kortix-master/src/services/secret-store.ts +156 -0
- package/kortix-master/tsconfig.json +14 -0
- package/opencode/agents/kortix-browser.md +142 -0
- package/opencode/agents/kortix-build.md +62 -0
- package/opencode/agents/kortix-explore.md +66 -0
- package/opencode/agents/kortix-image-gen.md +33 -0
- package/opencode/agents/kortix-main.md +450 -0
- package/opencode/agents/kortix-plan.md +100 -0
- package/opencode/agents/kortix-research.md +84 -0
- package/opencode/agents/kortix-sheets.md +61 -0
- package/opencode/agents/kortix-slides.md +64 -0
- package/opencode/agents/kortix-web-dev.md +572 -0
- package/opencode/commands/email.md +36 -0
- package/opencode/commands/init.md +43 -0
- package/opencode/commands/journal.md +44 -0
- package/opencode/commands/memory-init.md +81 -0
- package/opencode/commands/memory-search.md +50 -0
- package/opencode/commands/memory-status.md +56 -0
- package/opencode/commands/research.md +36 -0
- package/opencode/commands/search.md +38 -0
- package/opencode/commands/slides.md +32 -0
- package/opencode/commands/spreadsheet.md +30 -0
- package/opencode/memory.json +37 -0
- package/opencode/ocx.jsonc +10 -0
- package/opencode/opencode.jsonc +103 -0
- package/opencode/package.json +25 -0
- package/opencode/patches/apply.sh +19 -0
- package/opencode/patches/opencode-pty-spawn.txt +49 -0
- package/opencode/plugin/background-agents.ts.disabled +483 -0
- package/opencode/plugin/kdco-primitives/get-project-id.ts +172 -0
- package/opencode/plugin/kdco-primitives/index.ts +26 -0
- package/opencode/plugin/kdco-primitives/log-warn.ts +51 -0
- package/opencode/plugin/kdco-primitives/mutex.ts +122 -0
- package/opencode/plugin/kdco-primitives/shell.ts +138 -0
- package/opencode/plugin/kdco-primitives/temp.ts +36 -0
- package/opencode/plugin/kdco-primitives/terminal-detect.ts +34 -0
- package/opencode/plugin/kdco-primitives/types.ts +13 -0
- package/opencode/plugin/kdco-primitives/with-timeout.ts +84 -0
- package/opencode/plugin/memory.ts +306 -0
- package/opencode/plugin/worktree/state.ts +412 -0
- package/opencode/plugin/worktree/terminal.ts +1002 -0
- package/opencode/plugin/worktree.ts +861 -0
- package/opencode/skills/KORTIX-browser/SKILL.md +478 -0
- package/opencode/skills/KORTIX-cron-triggers/SKILL.md +173 -0
- package/opencode/skills/KORTIX-deep-research/SKILL.md +278 -0
- package/opencode/skills/KORTIX-docx/SKILL.md +398 -0
- package/opencode/skills/KORTIX-docx/scripts/__init__.py +1 -0
- package/opencode/skills/KORTIX-docx/scripts/accept_changes.py +104 -0
- package/opencode/skills/KORTIX-docx/scripts/comment.py +244 -0
- package/opencode/skills/KORTIX-docx/scripts/office/helpers/__init__.py +0 -0
- package/opencode/skills/KORTIX-docx/scripts/office/helpers/merge_runs.py +199 -0
- package/opencode/skills/KORTIX-docx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/opencode/skills/KORTIX-docx/scripts/office/pack.py +159 -0
- package/opencode/skills/KORTIX-docx/scripts/office/soffice.py +183 -0
- package/opencode/skills/KORTIX-docx/scripts/office/unpack.py +132 -0
- package/opencode/skills/KORTIX-docx/scripts/office/validate.py +111 -0
- package/opencode/skills/KORTIX-docx/scripts/office/validators/__init__.py +15 -0
- package/opencode/skills/KORTIX-docx/scripts/office/validators/base.py +847 -0
- package/opencode/skills/KORTIX-docx/scripts/office/validators/docx.py +446 -0
- package/opencode/skills/KORTIX-docx/scripts/office/validators/pptx.py +275 -0
- package/opencode/skills/KORTIX-docx/scripts/office/validators/redlining.py +247 -0
- package/opencode/skills/KORTIX-docx/scripts/render_docx.py +179 -0
- package/opencode/skills/KORTIX-docx/scripts/templates/comments.xml +3 -0
- package/opencode/skills/KORTIX-docx/scripts/templates/commentsExtended.xml +3 -0
- package/opencode/skills/KORTIX-docx/scripts/templates/commentsExtensible.xml +3 -0
- package/opencode/skills/KORTIX-docx/scripts/templates/commentsIds.xml +3 -0
- package/opencode/skills/KORTIX-docx/scripts/templates/people.xml +3 -0
- package/opencode/skills/KORTIX-domain-research/SKILL.md +96 -0
- package/opencode/skills/KORTIX-domain-research/scripts/domain-lookup.py +810 -0
- package/opencode/skills/KORTIX-elevenlabs/SKILL.md +230 -0
- package/opencode/skills/KORTIX-elevenlabs/scripts/tts.py +389 -0
- package/opencode/skills/KORTIX-email/SKILL.md +145 -0
- package/opencode/skills/KORTIX-legal-writer/SKILL.md +409 -0
- package/opencode/skills/KORTIX-legal-writer/references/bluebook.md +152 -0
- package/opencode/skills/KORTIX-legal-writer/references/document-types.md +416 -0
- package/opencode/skills/KORTIX-legal-writer/scripts/courtlistener.py +291 -0
- package/opencode/skills/KORTIX-legal-writer/scripts/ecfr_lookup.py +299 -0
- package/opencode/skills/KORTIX-legal-writer/scripts/verify-legal.py +507 -0
- package/opencode/skills/KORTIX-logo-creator/SKILL.md +293 -0
- package/opencode/skills/KORTIX-logo-creator/references/prompt-patterns.md +134 -0
- package/opencode/skills/KORTIX-logo-creator/scripts/compose_logo.py +406 -0
- package/opencode/skills/KORTIX-logo-creator/scripts/create_logo_sheet.py +258 -0
- package/opencode/skills/KORTIX-logo-creator/scripts/remove_bg.py +96 -0
- package/opencode/skills/KORTIX-memory/SKILL.md +261 -0
- package/opencode/skills/KORTIX-memory/scripts/export-sessions.py +409 -0
- package/opencode/skills/KORTIX-paper-creator/SKILL.md +549 -0
- package/opencode/skills/KORTIX-paper-creator/assets/template.tex +101 -0
- package/opencode/skills/KORTIX-paper-creator/scripts/compile.sh +177 -0
- package/opencode/skills/KORTIX-paper-creator/scripts/openalex_to_bibtex.py +220 -0
- package/opencode/skills/KORTIX-paper-creator/scripts/verify.sh +354 -0
- package/opencode/skills/KORTIX-paper-search/SKILL.md +418 -0
- package/opencode/skills/KORTIX-pdf/SKILL.md +232 -0
- package/opencode/skills/KORTIX-pdf/forms.md +36 -0
- package/opencode/skills/KORTIX-pdf/reference.md +105 -0
- package/opencode/skills/KORTIX-pdf/scripts/check_bounding_boxes.py +65 -0
- package/opencode/skills/KORTIX-pdf/scripts/check_fillable_fields.py +11 -0
- package/opencode/skills/KORTIX-pdf/scripts/convert_pdf_to_images.py +33 -0
- package/opencode/skills/KORTIX-pdf/scripts/create_validation_image.py +37 -0
- package/opencode/skills/KORTIX-pdf/scripts/extract_form_field_info.py +122 -0
- package/opencode/skills/KORTIX-pdf/scripts/extract_form_structure.py +115 -0
- package/opencode/skills/KORTIX-pdf/scripts/fill_fillable_fields.py +98 -0
- package/opencode/skills/KORTIX-pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
- package/opencode/skills/KORTIX-plan/SKILL.md +228 -0
- package/opencode/skills/KORTIX-presentation-viewer/SKILL.md +87 -0
- package/opencode/skills/KORTIX-presentation-viewer/serve.ts +136 -0
- package/opencode/skills/KORTIX-presentation-viewer/viewer.html +559 -0
- package/opencode/skills/KORTIX-presentations/SKILL.md +344 -0
- package/opencode/skills/KORTIX-remotion/SKILL.md +56 -0
- package/opencode/skills/KORTIX-remotion/rules/3d.md +86 -0
- package/opencode/skills/KORTIX-remotion/rules/animations.md +29 -0
- package/opencode/skills/KORTIX-remotion/rules/assets.md +78 -0
- package/opencode/skills/KORTIX-remotion/rules/audio-visualization.md +198 -0
- package/opencode/skills/KORTIX-remotion/rules/audio.md +169 -0
- package/opencode/skills/KORTIX-remotion/rules/calculate-metadata.md +104 -0
- package/opencode/skills/KORTIX-remotion/rules/can-decode.md +75 -0
- package/opencode/skills/KORTIX-remotion/rules/charts.md +120 -0
- package/opencode/skills/KORTIX-remotion/rules/compositions.md +141 -0
- package/opencode/skills/KORTIX-remotion/rules/display-captions.md +184 -0
- package/opencode/skills/KORTIX-remotion/rules/extract-frames.md +229 -0
- package/opencode/skills/KORTIX-remotion/rules/ffmpeg.md +38 -0
- package/opencode/skills/KORTIX-remotion/rules/fonts.md +152 -0
- package/opencode/skills/KORTIX-remotion/rules/get-audio-duration.md +58 -0
- package/opencode/skills/KORTIX-remotion/rules/get-video-dimensions.md +68 -0
- package/opencode/skills/KORTIX-remotion/rules/get-video-duration.md +58 -0
- package/opencode/skills/KORTIX-remotion/rules/gifs.md +141 -0
- package/opencode/skills/KORTIX-remotion/rules/images.md +130 -0
- package/opencode/skills/KORTIX-remotion/rules/import-srt-captions.md +69 -0
- package/opencode/skills/KORTIX-remotion/rules/light-leaks.md +73 -0
- package/opencode/skills/KORTIX-remotion/rules/lottie.md +68 -0
- package/opencode/skills/KORTIX-remotion/rules/maps.md +401 -0
- package/opencode/skills/KORTIX-remotion/rules/measuring-dom-nodes.md +35 -0
- package/opencode/skills/KORTIX-remotion/rules/measuring-text.md +143 -0
- package/opencode/skills/KORTIX-remotion/rules/parameters.md +98 -0
- package/opencode/skills/KORTIX-remotion/rules/sequencing.md +118 -0
- package/opencode/skills/KORTIX-remotion/rules/subtitles.md +36 -0
- package/opencode/skills/KORTIX-remotion/rules/tailwind.md +11 -0
- package/opencode/skills/KORTIX-remotion/rules/text-animations.md +20 -0
- package/opencode/skills/KORTIX-remotion/rules/timing.md +179 -0
- package/opencode/skills/KORTIX-remotion/rules/transcribe-captions.md +70 -0
- package/opencode/skills/KORTIX-remotion/rules/transitions.md +197 -0
- package/opencode/skills/KORTIX-remotion/rules/transparent-videos.md +106 -0
- package/opencode/skills/KORTIX-remotion/rules/trimming.md +53 -0
- package/opencode/skills/KORTIX-remotion/rules/videos.md +171 -0
- package/opencode/skills/KORTIX-secrets/SKILL.md +280 -0
- package/opencode/skills/KORTIX-semantic-search/SKILL.md +213 -0
- package/opencode/skills/KORTIX-session-search/SKILL.md +807 -0
- package/opencode/skills/KORTIX-session-search/Untitled +1 -0
- package/opencode/skills/KORTIX-skill-creator/SKILL.md +163 -0
- package/opencode/skills/KORTIX-web-research/SKILL.md +69 -0
- package/opencode/skills/KORTIX-xlsx/LICENSE.txt +30 -0
- package/opencode/skills/KORTIX-xlsx/SKILL.md +549 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/helpers/__init__.py +0 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/helpers/merge_runs.py +199 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/pack.py +159 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/soffice.py +183 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/unpack.py +132 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/validate.py +111 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/validators/__init__.py +15 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/validators/base.py +847 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/validators/docx.py +446 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/validators/pptx.py +275 -0
- package/opencode/skills/KORTIX-xlsx/scripts/office/validators/redlining.py +247 -0
- package/opencode/skills/KORTIX-xlsx/scripts/recalc.py +184 -0
- package/opencode/tools/image-gen.ts +342 -0
- package/opencode/tools/image-search.ts +190 -0
- package/opencode/tools/memory-get.ts +168 -0
- package/opencode/tools/memory-search.ts +247 -0
- package/opencode/tools/presentation-gen.ts +723 -0
- package/opencode/tools/scrape-webpage.ts +115 -0
- package/opencode/tools/scripts/.python-version +1 -0
- package/opencode/tools/scripts/convert_pdf.py +184 -0
- package/opencode/tools/scripts/convert_pptx.py +562 -0
- package/opencode/tools/scripts/pyproject.toml +11 -0
- package/opencode/tools/scripts/uv.lock +287 -0
- package/opencode/tools/scripts/validate_slide.py +74 -0
- package/opencode/tools/show-user.ts +217 -0
- package/opencode/tools/tests/e2e-presentation-fix.ts +277 -0
- package/opencode/tools/tests/image-gen.test.ts +215 -0
- package/opencode/tools/tests/image-search.test.ts +125 -0
- package/opencode/tools/tests/memory-system-benchmark.ts +1076 -0
- package/opencode/tools/tests/presentation-gen.test.ts +389 -0
- package/opencode/tools/tests/scrape-webpage.test.ts +74 -0
- package/opencode/tools/tests/show-user.test.ts +241 -0
- package/opencode/tools/tests/video-gen.test.ts +110 -0
- package/opencode/tools/tests/web-search.test.ts +106 -0
- package/opencode/tools/video-gen.ts +200 -0
- package/opencode/tools/web-search.ts +153 -0
- package/opencode/tsconfig.json +29 -0
- package/package.json +36 -0
- package/patch-agent-browser.js +100 -0
- package/postinstall.sh +88 -0
- package/services/KORTIX-presentation-viewer/run +37 -0
- package/services/agent-browser-viewer/run +48 -0
- package/services/kortix-master/run +16 -0
- package/services/lss-sync/run +22 -0
- package/services/opencode-serve/run +25 -0
- package/services/opencode-web/run +21 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: measuring-text
|
|
3
|
+
description: Measuring text dimensions, fitting text to containers, and checking overflow
|
|
4
|
+
metadata:
|
|
5
|
+
tags: measure, text, layout, dimensions, fitText, fillTextBox
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Measuring text in Remotion
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
Install @remotion/layout-utils if it is not already installed:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx remotion add @remotion/layout-utils # If project uses npm
|
|
16
|
+
bunx remotion add @remotion/layout-utils # If project uses bun
|
|
17
|
+
yarn remotion add @remotion/layout-utils # If project uses yarn
|
|
18
|
+
pnpm exec remotion add @remotion/layout-utils # If project uses pnpm
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Measuring text dimensions
|
|
22
|
+
|
|
23
|
+
Use `measureText()` to calculate the width and height of text:
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { measureText } from "@remotion/layout-utils";
|
|
27
|
+
|
|
28
|
+
const { width, height } = measureText({
|
|
29
|
+
text: "Hello World",
|
|
30
|
+
fontFamily: "Arial",
|
|
31
|
+
fontSize: 32,
|
|
32
|
+
fontWeight: "bold",
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Results are cached - duplicate calls return the cached result.
|
|
37
|
+
|
|
38
|
+
## Fitting text to a width
|
|
39
|
+
|
|
40
|
+
Use `fitText()` to find the optimal font size for a container:
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { fitText } from "@remotion/layout-utils";
|
|
44
|
+
|
|
45
|
+
const { fontSize } = fitText({
|
|
46
|
+
text: "Hello World",
|
|
47
|
+
withinWidth: 600,
|
|
48
|
+
fontFamily: "Inter",
|
|
49
|
+
fontWeight: "bold",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
style={{
|
|
55
|
+
fontSize: Math.min(fontSize, 80), // Cap at 80px
|
|
56
|
+
fontFamily: "Inter",
|
|
57
|
+
fontWeight: "bold",
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
Hello World
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Checking text overflow
|
|
66
|
+
|
|
67
|
+
Use `fillTextBox()` to check if text exceeds a box:
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { fillTextBox } from "@remotion/layout-utils";
|
|
71
|
+
|
|
72
|
+
const box = fillTextBox({ maxBoxWidth: 400, maxLines: 3 });
|
|
73
|
+
|
|
74
|
+
const words = ["Hello", "World", "This", "is", "a", "test"];
|
|
75
|
+
for (const word of words) {
|
|
76
|
+
const { exceedsBox } = box.add({
|
|
77
|
+
text: word + " ",
|
|
78
|
+
fontFamily: "Arial",
|
|
79
|
+
fontSize: 24,
|
|
80
|
+
});
|
|
81
|
+
if (exceedsBox) {
|
|
82
|
+
// Text would overflow, handle accordingly
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Best practices
|
|
89
|
+
|
|
90
|
+
**Load fonts first:** Only call measurement functions after fonts are loaded.
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { loadFont } from "@remotion/google-fonts/Inter";
|
|
94
|
+
|
|
95
|
+
const { fontFamily, waitUntilDone } = loadFont("normal", {
|
|
96
|
+
weights: ["400"],
|
|
97
|
+
subsets: ["latin"],
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
waitUntilDone().then(() => {
|
|
101
|
+
// Now safe to measure
|
|
102
|
+
const { width } = measureText({
|
|
103
|
+
text: "Hello",
|
|
104
|
+
fontFamily,
|
|
105
|
+
fontSize: 32,
|
|
106
|
+
});
|
|
107
|
+
})
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Use validateFontIsLoaded:** Catch font loading issues early:
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
measureText({
|
|
114
|
+
text: "Hello",
|
|
115
|
+
fontFamily: "MyCustomFont",
|
|
116
|
+
fontSize: 32,
|
|
117
|
+
validateFontIsLoaded: true, // Throws if font not loaded
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Match font properties:** Use the same properties for measurement and rendering:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
const fontStyle = {
|
|
125
|
+
fontFamily: "Inter",
|
|
126
|
+
fontSize: 32,
|
|
127
|
+
fontWeight: "bold" as const,
|
|
128
|
+
letterSpacing: "0.5px",
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const { width } = measureText({
|
|
132
|
+
text: "Hello",
|
|
133
|
+
...fontStyle,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
return <div style={fontStyle}>Hello</div>;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Avoid padding and border:** Use `outline` instead of `border` to prevent layout differences:
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
<div style={{ outline: "2px solid red" }}>Text</div>
|
|
143
|
+
```
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: parameters
|
|
3
|
+
description: Make a video parametrizable by adding a Zod schema
|
|
4
|
+
metadata:
|
|
5
|
+
tags: parameters, zod, schema
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
To make a video parametrizable, a Zod schema can be added to a composition.
|
|
9
|
+
|
|
10
|
+
First, `zod` must be installed - it must be exactly version `3.22.3`.
|
|
11
|
+
|
|
12
|
+
Search the project for lockfiles and run the correct command depending on the package manager:
|
|
13
|
+
|
|
14
|
+
If `package-lock.json` is found, use the following command:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm i zod@3.22.3
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
If `bun.lockb` is found, use the following command:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bun i zod@3.22.3
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If `yarn.lock` is found, use the following command:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
yarn add zod@3.22.3
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If `pnpm-lock.yaml` is found, use the following command:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm i zod@3.22.3
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then, a Zod schema can be defined alongside the component:
|
|
39
|
+
|
|
40
|
+
```tsx title="src/MyComposition.tsx"
|
|
41
|
+
import {z} from 'zod';
|
|
42
|
+
|
|
43
|
+
export const MyCompositionSchema = z.object({
|
|
44
|
+
title: z.string(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const MyComponent: React.FC<z.infer<typeof MyCompositionSchema>> = () => {
|
|
48
|
+
return (
|
|
49
|
+
<div>
|
|
50
|
+
<h1>{props.title}</h1>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
In the root file, the schema can be passed to the composition:
|
|
57
|
+
|
|
58
|
+
```tsx title="src/Root.tsx"
|
|
59
|
+
import {Composition} from 'remotion';
|
|
60
|
+
import {MycComponent, MyCompositionSchema} from './MyComposition';
|
|
61
|
+
|
|
62
|
+
export const RemotionRoot = () => {
|
|
63
|
+
return <Composition id="MyComposition" component={MyComponent} durationInFrames={100} fps={30} width={1080} height={1080} defaultProps={{title: 'Hello World'}} schema={MyCompositionSchema} />;
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Now, the user can edit the parameter visually in the sidebar.
|
|
68
|
+
|
|
69
|
+
All schemas that are supported by Zod are supported by Remotion.
|
|
70
|
+
|
|
71
|
+
Remotion requires that the top-level type is a z.object(), because the collection of props of a React component is always an object.
|
|
72
|
+
|
|
73
|
+
## Color picker
|
|
74
|
+
|
|
75
|
+
For adding a color picker, use `zColor()` from `@remotion/zod-types`.
|
|
76
|
+
|
|
77
|
+
If it is not installed, use the following command:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npx remotion add @remotion/zod-types # If project uses npm
|
|
81
|
+
bunx remotion add @remotion/zod-types # If project uses bun
|
|
82
|
+
yarn remotion add @remotion/zod-types # If project uses yarn
|
|
83
|
+
pnpm exec remotion add @remotion/zod-types # If project uses pnpm
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Then import `zColor` from `@remotion/zod-types`:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import {zColor} from '@remotion/zod-types';
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Then use it in the schema:
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
export const MyCompositionSchema = z.object({
|
|
96
|
+
color: zColor(),
|
|
97
|
+
});
|
|
98
|
+
```
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sequencing
|
|
3
|
+
description: Sequencing patterns for Remotion - delay, trim, limit duration of items
|
|
4
|
+
metadata:
|
|
5
|
+
tags: sequence, series, timing, delay, trim
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Use `<Sequence>` to delay when an element appears in the timeline.
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { Sequence } from "remotion";
|
|
12
|
+
|
|
13
|
+
const {fps} = useVideoConfig();
|
|
14
|
+
|
|
15
|
+
<Sequence from={1 * fps} durationInFrames={2 * fps} premountFor={1 * fps}>
|
|
16
|
+
<Title />
|
|
17
|
+
</Sequence>
|
|
18
|
+
<Sequence from={2 * fps} durationInFrames={2 * fps} premountFor={1 * fps}>
|
|
19
|
+
<Subtitle />
|
|
20
|
+
</Sequence>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This will by default wrap the component in an absolute fill element.
|
|
24
|
+
If the items should not be wrapped, use the `layout` prop:
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
<Sequence layout="none">
|
|
28
|
+
<Title />
|
|
29
|
+
</Sequence>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Premounting
|
|
33
|
+
|
|
34
|
+
This loads the component in the timeline before it is actually played.
|
|
35
|
+
Always premount any `<Sequence>`!
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
<Sequence premountFor={1 * fps}>
|
|
39
|
+
<Title />
|
|
40
|
+
</Sequence>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Series
|
|
44
|
+
|
|
45
|
+
Use `<Series>` when elements should play one after another without overlap.
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import {Series} from 'remotion';
|
|
49
|
+
|
|
50
|
+
<Series>
|
|
51
|
+
<Series.Sequence durationInFrames={45}>
|
|
52
|
+
<Intro />
|
|
53
|
+
</Series.Sequence>
|
|
54
|
+
<Series.Sequence durationInFrames={60}>
|
|
55
|
+
<MainContent />
|
|
56
|
+
</Series.Sequence>
|
|
57
|
+
<Series.Sequence durationInFrames={30}>
|
|
58
|
+
<Outro />
|
|
59
|
+
</Series.Sequence>
|
|
60
|
+
</Series>;
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Same as with `<Sequence>`, the items will be wrapped in an absolute fill element by default when using `<Series.Sequence>`, unless the `layout` prop is set to `none`.
|
|
64
|
+
|
|
65
|
+
### Series with overlaps
|
|
66
|
+
|
|
67
|
+
Use negative offset for overlapping sequences:
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
<Series>
|
|
71
|
+
<Series.Sequence durationInFrames={60}>
|
|
72
|
+
<SceneA />
|
|
73
|
+
</Series.Sequence>
|
|
74
|
+
<Series.Sequence offset={-15} durationInFrames={60}>
|
|
75
|
+
{/* Starts 15 frames before SceneA ends */}
|
|
76
|
+
<SceneB />
|
|
77
|
+
</Series.Sequence>
|
|
78
|
+
</Series>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Frame References Inside Sequences
|
|
82
|
+
|
|
83
|
+
Inside a Sequence, `useCurrentFrame()` returns the local frame (starting from 0):
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<Sequence from={60} durationInFrames={30}>
|
|
87
|
+
<MyComponent />
|
|
88
|
+
{/* Inside MyComponent, useCurrentFrame() returns 0-29, not 60-89 */}
|
|
89
|
+
</Sequence>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Nested Sequences
|
|
93
|
+
|
|
94
|
+
Sequences can be nested for complex timing:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
<Sequence from={0} durationInFrames={120}>
|
|
98
|
+
<Background />
|
|
99
|
+
<Sequence from={15} durationInFrames={90} layout="none">
|
|
100
|
+
<Title />
|
|
101
|
+
</Sequence>
|
|
102
|
+
<Sequence from={45} durationInFrames={60} layout="none">
|
|
103
|
+
<Subtitle />
|
|
104
|
+
</Sequence>
|
|
105
|
+
</Sequence>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Nesting compositions within another
|
|
109
|
+
|
|
110
|
+
To add a composition within another composition, you can use the `<Sequence>` component with a `width` and `height` prop to specify the size of the composition.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<AbsoluteFill>
|
|
114
|
+
<Sequence width={COMPOSITION_WIDTH} height={COMPOSITION_HEIGHT}>
|
|
115
|
+
<CompositionComponent />
|
|
116
|
+
</Sequence>
|
|
117
|
+
</AbsoluteFill>
|
|
118
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: subtitles
|
|
3
|
+
description: subtitles and caption rules
|
|
4
|
+
metadata:
|
|
5
|
+
tags: subtitles, captions, remotion, json
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
All captions must be processed in JSON. The captions must use the `Caption` type which is the following:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import type { Caption } from "@remotion/captions";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
This is the definition:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
type Caption = {
|
|
18
|
+
text: string;
|
|
19
|
+
startMs: number;
|
|
20
|
+
endMs: number;
|
|
21
|
+
timestampMs: number | null;
|
|
22
|
+
confidence: number | null;
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Generating captions
|
|
27
|
+
|
|
28
|
+
To transcribe video and audio files to generate captions, load the [./transcribe-captions.md](./transcribe-captions.md) file for more instructions.
|
|
29
|
+
|
|
30
|
+
## Displaying captions
|
|
31
|
+
|
|
32
|
+
To display captions in your video, load the [./display-captions.md](./display-captions.md) file for more instructions.
|
|
33
|
+
|
|
34
|
+
## Importing captions
|
|
35
|
+
|
|
36
|
+
To import captions from a .srt file, load the [./import-srt-captions.md](./import-srt-captions.md) file for more instructions.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tailwind
|
|
3
|
+
description: Using TailwindCSS in Remotion.
|
|
4
|
+
metadata:
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You can and should use TailwindCSS in Remotion, if TailwindCSS is installed in the project.
|
|
8
|
+
|
|
9
|
+
Don't use `transition-*` or `animate-*` classes - always animate using the `useCurrentFrame()` hook.
|
|
10
|
+
|
|
11
|
+
Tailwind must be installed and enabled first in a Remotion project - fetch https://www.remotion.dev/docs/tailwind using WebFetch for instructions.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: text-animations
|
|
3
|
+
description: Typography and text animation patterns for Remotion.
|
|
4
|
+
metadata:
|
|
5
|
+
tags: typography, text, typewriter, highlighter ken
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Text animations
|
|
9
|
+
|
|
10
|
+
Based on `useCurrentFrame()`, reduce the string character by character to create a typewriter effect.
|
|
11
|
+
|
|
12
|
+
## Typewriter Effect
|
|
13
|
+
|
|
14
|
+
See [Typewriter](assets/text-animations-typewriter.tsx) for an advanced example with a blinking cursor and a pause after the first sentence.
|
|
15
|
+
|
|
16
|
+
Always use string slicing for typewriter effects. Never use per-character opacity.
|
|
17
|
+
|
|
18
|
+
## Word Highlighting
|
|
19
|
+
|
|
20
|
+
See [Word Highlight](assets/text-animations-word-highlight.tsx) for an example for how a word highlight is animated, like with a highlighter pen.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: timing
|
|
3
|
+
description: Interpolation curves in Remotion - linear, easing, spring animations
|
|
4
|
+
metadata:
|
|
5
|
+
tags: spring, bounce, easing, interpolation
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
A simple linear interpolation is done using the `interpolate` function.
|
|
9
|
+
|
|
10
|
+
```ts title="Going from 0 to 1 over 100 frames"
|
|
11
|
+
import {interpolate} from 'remotion';
|
|
12
|
+
|
|
13
|
+
const opacity = interpolate(frame, [0, 100], [0, 1]);
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
By default, the values are not clamped, so the value can go outside the range [0, 1].
|
|
17
|
+
Here is how they can be clamped:
|
|
18
|
+
|
|
19
|
+
```ts title="Going from 0 to 1 over 100 frames with extrapolation"
|
|
20
|
+
const opacity = interpolate(frame, [0, 100], [0, 1], {
|
|
21
|
+
extrapolateRight: 'clamp',
|
|
22
|
+
extrapolateLeft: 'clamp',
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Spring animations
|
|
27
|
+
|
|
28
|
+
Spring animations have a more natural motion.
|
|
29
|
+
They go from 0 to 1 over time.
|
|
30
|
+
|
|
31
|
+
```ts title="Spring animation from 0 to 1 over 100 frames"
|
|
32
|
+
import {spring, useCurrentFrame, useVideoConfig} from 'remotion';
|
|
33
|
+
|
|
34
|
+
const frame = useCurrentFrame();
|
|
35
|
+
const {fps} = useVideoConfig();
|
|
36
|
+
|
|
37
|
+
const scale = spring({
|
|
38
|
+
frame,
|
|
39
|
+
fps,
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Physical properties
|
|
44
|
+
|
|
45
|
+
The default configuration is: `mass: 1, damping: 10, stiffness: 100`.
|
|
46
|
+
This leads to the animation having a bit of bounce before it settles.
|
|
47
|
+
|
|
48
|
+
The config can be overwritten like this:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
const scale = spring({
|
|
52
|
+
frame,
|
|
53
|
+
fps,
|
|
54
|
+
config: {damping: 200},
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The recommended configuration for a natural motion without a bounce is: `{ damping: 200 }`.
|
|
59
|
+
|
|
60
|
+
Here are some common configurations:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
const smooth = {damping: 200}; // Smooth, no bounce (subtle reveals)
|
|
64
|
+
const snappy = {damping: 20, stiffness: 200}; // Snappy, minimal bounce (UI elements)
|
|
65
|
+
const bouncy = {damping: 8}; // Bouncy entrance (playful animations)
|
|
66
|
+
const heavy = {damping: 15, stiffness: 80, mass: 2}; // Heavy, slow, small bounce
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Delay
|
|
70
|
+
|
|
71
|
+
The animation starts immediately by default.
|
|
72
|
+
Use the `delay` parameter to delay the animation by a number of frames.
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
const entrance = spring({
|
|
76
|
+
frame: frame - ENTRANCE_DELAY,
|
|
77
|
+
fps,
|
|
78
|
+
delay: 20,
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Duration
|
|
83
|
+
|
|
84
|
+
A `spring()` has a natural duration based on the physical properties.
|
|
85
|
+
To stretch the animation to a specific duration, use the `durationInFrames` parameter.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
const spring = spring({
|
|
89
|
+
frame,
|
|
90
|
+
fps,
|
|
91
|
+
durationInFrames: 40,
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Combining spring() with interpolate()
|
|
96
|
+
|
|
97
|
+
Map spring output (0-1) to custom ranges:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
const springProgress = spring({
|
|
101
|
+
frame,
|
|
102
|
+
fps,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Map to rotation
|
|
106
|
+
const rotation = interpolate(springProgress, [0, 1], [0, 360]);
|
|
107
|
+
|
|
108
|
+
<div style={{rotate: rotation + 'deg'}} />;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Adding springs
|
|
112
|
+
|
|
113
|
+
Springs return just numbers, so math can be performed:
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
const frame = useCurrentFrame();
|
|
117
|
+
const {fps, durationInFrames} = useVideoConfig();
|
|
118
|
+
|
|
119
|
+
const inAnimation = spring({
|
|
120
|
+
frame,
|
|
121
|
+
fps,
|
|
122
|
+
});
|
|
123
|
+
const outAnimation = spring({
|
|
124
|
+
frame,
|
|
125
|
+
fps,
|
|
126
|
+
durationInFrames: 1 * fps,
|
|
127
|
+
delay: durationInFrames - 1 * fps,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const scale = inAnimation - outAnimation;
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Easing
|
|
134
|
+
|
|
135
|
+
Easing can be added to the `interpolate` function:
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import {interpolate, Easing} from 'remotion';
|
|
139
|
+
|
|
140
|
+
const value1 = interpolate(frame, [0, 100], [0, 1], {
|
|
141
|
+
easing: Easing.inOut(Easing.quad),
|
|
142
|
+
extrapolateLeft: 'clamp',
|
|
143
|
+
extrapolateRight: 'clamp',
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The default easing is `Easing.linear`.
|
|
148
|
+
There are various other convexities:
|
|
149
|
+
|
|
150
|
+
- `Easing.in` for starting slow and accelerating
|
|
151
|
+
- `Easing.out` for starting fast and slowing down
|
|
152
|
+
- `Easing.inOut`
|
|
153
|
+
|
|
154
|
+
and curves (sorted from most linear to most curved):
|
|
155
|
+
|
|
156
|
+
- `Easing.quad`
|
|
157
|
+
- `Easing.sin`
|
|
158
|
+
- `Easing.exp`
|
|
159
|
+
- `Easing.circle`
|
|
160
|
+
|
|
161
|
+
Convexities and curves need be combined for an easing function:
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const value1 = interpolate(frame, [0, 100], [0, 1], {
|
|
165
|
+
easing: Easing.inOut(Easing.quad),
|
|
166
|
+
extrapolateLeft: 'clamp',
|
|
167
|
+
extrapolateRight: 'clamp',
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Cubic bezier curves are also supported:
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
const value1 = interpolate(frame, [0, 100], [0, 1], {
|
|
175
|
+
easing: Easing.bezier(0.8, 0.22, 0.96, 0.65),
|
|
176
|
+
extrapolateLeft: 'clamp',
|
|
177
|
+
extrapolateRight: 'clamp',
|
|
178
|
+
});
|
|
179
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: transcribe-captions
|
|
3
|
+
description: Transcribing audio to generate captions in Remotion
|
|
4
|
+
metadata:
|
|
5
|
+
tags: captions, transcribe, whisper, audio, speech-to-text
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Transcribing audio
|
|
9
|
+
|
|
10
|
+
To transcribe audio to generate captions in Remotion, you can use the [`transcribe()`](https://www.remotion.dev/docs/install-whisper-cpp/transcribe) function from the [`@remotion/install-whisper-cpp`](https://www.remotion.dev/docs/install-whisper-cpp) package.
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
First, the @remotion/install-whisper-cpp package needs to be installed.
|
|
15
|
+
If it is not installed, use the following command:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx remotion add @remotion/install-whisper-cpp
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Transcribing
|
|
22
|
+
|
|
23
|
+
Make a Node.js script to download Whisper.cpp and a model, and transcribe the audio.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import path from "path";
|
|
27
|
+
import {
|
|
28
|
+
downloadWhisperModel,
|
|
29
|
+
installWhisperCpp,
|
|
30
|
+
transcribe,
|
|
31
|
+
toCaptions,
|
|
32
|
+
} from "@remotion/install-whisper-cpp";
|
|
33
|
+
import fs from "fs";
|
|
34
|
+
|
|
35
|
+
const to = path.join(process.cwd(), "whisper.cpp");
|
|
36
|
+
|
|
37
|
+
await installWhisperCpp({
|
|
38
|
+
to,
|
|
39
|
+
version: "1.5.5",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
await downloadWhisperModel({
|
|
43
|
+
model: "medium.en",
|
|
44
|
+
folder: to,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Convert the audio to a 16KHz wav file first if needed:
|
|
48
|
+
// import {execSync} from 'child_process';
|
|
49
|
+
// execSync('ffmpeg -i /path/to/audio.mp4 -ar 16000 /path/to/audio.wav -y');
|
|
50
|
+
|
|
51
|
+
const whisperCppOutput = await transcribe({
|
|
52
|
+
model: "medium.en",
|
|
53
|
+
whisperPath: to,
|
|
54
|
+
whisperCppVersion: "1.5.5",
|
|
55
|
+
inputPath: "/path/to/audio123.wav",
|
|
56
|
+
tokenLevelTimestamps: true,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Optional: Apply our recommended postprocessing
|
|
60
|
+
const { captions } = toCaptions({
|
|
61
|
+
whisperCppOutput,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Write it to the public/ folder so it can be fetched from Remotion
|
|
65
|
+
fs.writeFileSync("captions123.json", JSON.stringify(captions, null, 2));
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Transcribe each clip individually and create multiple JSON files.
|
|
69
|
+
|
|
70
|
+
See [Displaying captions](display-captions.md) for how to display the captions in Remotion.
|