@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,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fonts
|
|
3
|
+
description: Loading Google Fonts and local fonts in Remotion
|
|
4
|
+
metadata:
|
|
5
|
+
tags: fonts, google-fonts, typography, text
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Using fonts in Remotion
|
|
9
|
+
|
|
10
|
+
## Google Fonts with @remotion/google-fonts
|
|
11
|
+
|
|
12
|
+
The recommended way to use Google Fonts. It's type-safe and automatically blocks rendering until the font is ready.
|
|
13
|
+
|
|
14
|
+
### Prerequisites
|
|
15
|
+
|
|
16
|
+
First, the @remotion/google-fonts package needs to be installed.
|
|
17
|
+
If it is not installed, use the following command:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx remotion add @remotion/google-fonts # If project uses npm
|
|
21
|
+
bunx remotion add @remotion/google-fonts # If project uses bun
|
|
22
|
+
yarn remotion add @remotion/google-fonts # If project uses yarn
|
|
23
|
+
pnpm exec remotion add @remotion/google-fonts # If project uses pnpm
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { loadFont } from "@remotion/google-fonts/Lobster";
|
|
28
|
+
|
|
29
|
+
const { fontFamily } = loadFont();
|
|
30
|
+
|
|
31
|
+
export const MyComposition = () => {
|
|
32
|
+
return <div style={{ fontFamily }}>Hello World</div>;
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Preferrably, specify only needed weights and subsets to reduce file size:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { loadFont } from "@remotion/google-fonts/Roboto";
|
|
40
|
+
|
|
41
|
+
const { fontFamily } = loadFont("normal", {
|
|
42
|
+
weights: ["400", "700"],
|
|
43
|
+
subsets: ["latin"],
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Waiting for font to load
|
|
48
|
+
|
|
49
|
+
Use `waitUntilDone()` if you need to know when the font is ready:
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { loadFont } from "@remotion/google-fonts/Lobster";
|
|
53
|
+
|
|
54
|
+
const { fontFamily, waitUntilDone } = loadFont();
|
|
55
|
+
|
|
56
|
+
await waitUntilDone();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Local fonts with @remotion/fonts
|
|
60
|
+
|
|
61
|
+
For local font files, use the `@remotion/fonts` package.
|
|
62
|
+
|
|
63
|
+
### Prerequisites
|
|
64
|
+
|
|
65
|
+
First, install @remotion/fonts:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npx remotion add @remotion/fonts # If project uses npm
|
|
69
|
+
bunx remotion add @remotion/fonts # If project uses bun
|
|
70
|
+
yarn remotion add @remotion/fonts # If project uses yarn
|
|
71
|
+
pnpm exec remotion add @remotion/fonts # If project uses pnpm
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Loading a local font
|
|
75
|
+
|
|
76
|
+
Place your font file in the `public/` folder and use `loadFont()`:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { loadFont } from "@remotion/fonts";
|
|
80
|
+
import { staticFile } from "remotion";
|
|
81
|
+
|
|
82
|
+
await loadFont({
|
|
83
|
+
family: "MyFont",
|
|
84
|
+
url: staticFile("MyFont-Regular.woff2"),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const MyComposition = () => {
|
|
88
|
+
return <div style={{ fontFamily: "MyFont" }}>Hello World</div>;
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Loading multiple weights
|
|
93
|
+
|
|
94
|
+
Load each weight separately with the same family name:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { loadFont } from "@remotion/fonts";
|
|
98
|
+
import { staticFile } from "remotion";
|
|
99
|
+
|
|
100
|
+
await Promise.all([
|
|
101
|
+
loadFont({
|
|
102
|
+
family: "Inter",
|
|
103
|
+
url: staticFile("Inter-Regular.woff2"),
|
|
104
|
+
weight: "400",
|
|
105
|
+
}),
|
|
106
|
+
loadFont({
|
|
107
|
+
family: "Inter",
|
|
108
|
+
url: staticFile("Inter-Bold.woff2"),
|
|
109
|
+
weight: "700",
|
|
110
|
+
}),
|
|
111
|
+
]);
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Available options
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
loadFont({
|
|
118
|
+
family: "MyFont", // Required: name to use in CSS
|
|
119
|
+
url: staticFile("font.woff2"), // Required: font file URL
|
|
120
|
+
format: "woff2", // Optional: auto-detected from extension
|
|
121
|
+
weight: "400", // Optional: font weight
|
|
122
|
+
style: "normal", // Optional: normal or italic
|
|
123
|
+
display: "block", // Optional: font-display behavior
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Using in components
|
|
128
|
+
|
|
129
|
+
Call `loadFont()` at the top level of your component or in a separate file that's imported early:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { loadFont } from "@remotion/google-fonts/Montserrat";
|
|
133
|
+
|
|
134
|
+
const { fontFamily } = loadFont("normal", {
|
|
135
|
+
weights: ["400", "700"],
|
|
136
|
+
subsets: ["latin"],
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export const Title: React.FC<{ text: string }> = ({ text }) => {
|
|
140
|
+
return (
|
|
141
|
+
<h1
|
|
142
|
+
style={{
|
|
143
|
+
fontFamily,
|
|
144
|
+
fontSize: 80,
|
|
145
|
+
fontWeight: "bold",
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
{text}
|
|
149
|
+
</h1>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: get-audio-duration
|
|
3
|
+
description: Getting the duration of an audio file in seconds with Mediabunny
|
|
4
|
+
metadata:
|
|
5
|
+
tags: duration, audio, length, time, seconds, mp3, wav
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Getting audio duration with Mediabunny
|
|
9
|
+
|
|
10
|
+
Mediabunny can extract the duration of an audio file. It works in browser, Node.js, and Bun environments.
|
|
11
|
+
|
|
12
|
+
## Getting audio duration
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Input, ALL_FORMATS, UrlSource } from "mediabunny";
|
|
16
|
+
|
|
17
|
+
export const getAudioDuration = async (src: string) => {
|
|
18
|
+
const input = new Input({
|
|
19
|
+
formats: ALL_FORMATS,
|
|
20
|
+
source: new UrlSource(src, {
|
|
21
|
+
getRetryDelay: () => null,
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const durationInSeconds = await input.computeDuration();
|
|
26
|
+
return durationInSeconds;
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
const duration = await getAudioDuration("https://remotion.media/audio.mp3");
|
|
34
|
+
console.log(duration); // e.g. 180.5 (seconds)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Using with local files
|
|
38
|
+
|
|
39
|
+
For local files, use `FileSource` instead of `UrlSource`:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { Input, ALL_FORMATS, FileSource } from "mediabunny";
|
|
43
|
+
|
|
44
|
+
const input = new Input({
|
|
45
|
+
formats: ALL_FORMATS,
|
|
46
|
+
source: new FileSource(file), // File object from input or drag-drop
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const durationInSeconds = await input.computeDuration();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Using with staticFile in Remotion
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { staticFile } from "remotion";
|
|
56
|
+
|
|
57
|
+
const duration = await getAudioDuration(staticFile("audio.mp3"));
|
|
58
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: get-video-dimensions
|
|
3
|
+
description: Getting the width and height of a video file with Mediabunny
|
|
4
|
+
metadata:
|
|
5
|
+
tags: dimensions, width, height, resolution, size, video
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Getting video dimensions with Mediabunny
|
|
9
|
+
|
|
10
|
+
Mediabunny can extract the width and height of a video file. It works in browser, Node.js, and Bun environments.
|
|
11
|
+
|
|
12
|
+
## Getting video dimensions
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Input, ALL_FORMATS, UrlSource } from "mediabunny";
|
|
16
|
+
|
|
17
|
+
export const getVideoDimensions = async (src: string) => {
|
|
18
|
+
const input = new Input({
|
|
19
|
+
formats: ALL_FORMATS,
|
|
20
|
+
source: new UrlSource(src, {
|
|
21
|
+
getRetryDelay: () => null,
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const videoTrack = await input.getPrimaryVideoTrack();
|
|
26
|
+
if (!videoTrack) {
|
|
27
|
+
throw new Error("No video track found");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
width: videoTrack.displayWidth,
|
|
32
|
+
height: videoTrack.displayHeight,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
const dimensions = await getVideoDimensions("https://remotion.media/video.mp4");
|
|
41
|
+
console.log(dimensions.width); // e.g. 1920
|
|
42
|
+
console.log(dimensions.height); // e.g. 1080
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Using with local files
|
|
46
|
+
|
|
47
|
+
For local files, use `FileSource` instead of `UrlSource`:
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { Input, ALL_FORMATS, FileSource } from "mediabunny";
|
|
51
|
+
|
|
52
|
+
const input = new Input({
|
|
53
|
+
formats: ALL_FORMATS,
|
|
54
|
+
source: new FileSource(file), // File object from input or drag-drop
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const videoTrack = await input.getPrimaryVideoTrack();
|
|
58
|
+
const width = videoTrack.displayWidth;
|
|
59
|
+
const height = videoTrack.displayHeight;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Using with staticFile in Remotion
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { staticFile } from "remotion";
|
|
66
|
+
|
|
67
|
+
const dimensions = await getVideoDimensions(staticFile("video.mp4"));
|
|
68
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: get-video-duration
|
|
3
|
+
description: Getting the duration of a video file in seconds with Mediabunny
|
|
4
|
+
metadata:
|
|
5
|
+
tags: duration, video, length, time, seconds
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Getting video duration with Mediabunny
|
|
9
|
+
|
|
10
|
+
Mediabunny can extract the duration of a video file. It works in browser, Node.js, and Bun environments.
|
|
11
|
+
|
|
12
|
+
## Getting video duration
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Input, ALL_FORMATS, UrlSource } from "mediabunny";
|
|
16
|
+
|
|
17
|
+
export const getVideoDuration = async (src: string) => {
|
|
18
|
+
const input = new Input({
|
|
19
|
+
formats: ALL_FORMATS,
|
|
20
|
+
source: new UrlSource(src, {
|
|
21
|
+
getRetryDelay: () => null,
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const durationInSeconds = await input.computeDuration();
|
|
26
|
+
return durationInSeconds;
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
const duration = await getVideoDuration("https://remotion.media/video.mp4");
|
|
34
|
+
console.log(duration); // e.g. 10.5 (seconds)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Using with local files
|
|
38
|
+
|
|
39
|
+
For local files, use `FileSource` instead of `UrlSource`:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { Input, ALL_FORMATS, FileSource } from "mediabunny";
|
|
43
|
+
|
|
44
|
+
const input = new Input({
|
|
45
|
+
formats: ALL_FORMATS,
|
|
46
|
+
source: new FileSource(file), // File object from input or drag-drop
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const durationInSeconds = await input.computeDuration();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Using with staticFile in Remotion
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { staticFile } from "remotion";
|
|
56
|
+
|
|
57
|
+
const duration = await getVideoDuration(staticFile("video.mp4"));
|
|
58
|
+
```
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gif
|
|
3
|
+
description: Displaying GIFs, APNG, AVIF and WebP in Remotion
|
|
4
|
+
metadata:
|
|
5
|
+
tags: gif, animation, images, animated, apng, avif, webp
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Using Animated images in Remotion
|
|
9
|
+
|
|
10
|
+
## Basic usage
|
|
11
|
+
|
|
12
|
+
Use `<AnimatedImage>` to display a GIF, APNG, AVIF or WebP image synchronized with Remotion's timeline:
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { AnimatedImage, staticFile } from "remotion";
|
|
16
|
+
|
|
17
|
+
export const MyComposition = () => {
|
|
18
|
+
return (
|
|
19
|
+
<AnimatedImage src={staticFile("animation.gif")} width={500} height={500} />
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Remote URLs are also supported (must have CORS enabled):
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
<AnimatedImage
|
|
28
|
+
src="https://example.com/animation.gif"
|
|
29
|
+
width={500}
|
|
30
|
+
height={500}
|
|
31
|
+
/>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Sizing and fit
|
|
35
|
+
|
|
36
|
+
Control how the image fills its container with the `fit` prop:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
// Stretch to fill (default)
|
|
40
|
+
<AnimatedImage src={staticFile("animation.gif")} width={500} height={300} fit="fill" />
|
|
41
|
+
|
|
42
|
+
// Maintain aspect ratio, fit inside container
|
|
43
|
+
<AnimatedImage src={staticFile("animation.gif")} width={500} height={300} fit="contain" />
|
|
44
|
+
|
|
45
|
+
// Fill container, crop if needed
|
|
46
|
+
<AnimatedImage src={staticFile("animation.gif")} width={500} height={300} fit="cover" />
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Playback speed
|
|
50
|
+
|
|
51
|
+
Use `playbackRate` to control the animation speed:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
<AnimatedImage src={staticFile("animation.gif")} width={500} height={500} playbackRate={2} /> {/* 2x speed */}
|
|
55
|
+
<AnimatedImage src={staticFile("animation.gif")} width={500} height={500} playbackRate={0.5} /> {/* Half speed */}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Looping behavior
|
|
59
|
+
|
|
60
|
+
Control what happens when the animation finishes:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
// Loop indefinitely (default)
|
|
64
|
+
<AnimatedImage src={staticFile("animation.gif")} width={500} height={500} loopBehavior="loop" />
|
|
65
|
+
|
|
66
|
+
// Play once, show final frame
|
|
67
|
+
<AnimatedImage src={staticFile("animation.gif")} width={500} height={500} loopBehavior="pause-after-finish" />
|
|
68
|
+
|
|
69
|
+
// Play once, then clear canvas
|
|
70
|
+
<AnimatedImage src={staticFile("animation.gif")} width={500} height={500} loopBehavior="clear-after-finish" />
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Styling
|
|
74
|
+
|
|
75
|
+
Use the `style` prop for additional CSS (use `width` and `height` props for sizing):
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
<AnimatedImage
|
|
79
|
+
src={staticFile("animation.gif")}
|
|
80
|
+
width={500}
|
|
81
|
+
height={500}
|
|
82
|
+
style={{
|
|
83
|
+
borderRadius: 20,
|
|
84
|
+
position: "absolute",
|
|
85
|
+
top: 100,
|
|
86
|
+
left: 50,
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Getting GIF duration
|
|
92
|
+
|
|
93
|
+
Use `getGifDurationInSeconds()` from `@remotion/gif` to get the duration of a GIF.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx remotion add @remotion/gif
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { getGifDurationInSeconds } from "@remotion/gif";
|
|
101
|
+
import { staticFile } from "remotion";
|
|
102
|
+
|
|
103
|
+
const duration = await getGifDurationInSeconds(staticFile("animation.gif"));
|
|
104
|
+
console.log(duration); // e.g. 2.5
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
This is useful for setting the composition duration to match the GIF:
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import { getGifDurationInSeconds } from "@remotion/gif";
|
|
111
|
+
import { staticFile, CalculateMetadataFunction } from "remotion";
|
|
112
|
+
|
|
113
|
+
const calculateMetadata: CalculateMetadataFunction = async () => {
|
|
114
|
+
const duration = await getGifDurationInSeconds(staticFile("animation.gif"));
|
|
115
|
+
return {
|
|
116
|
+
durationInFrames: Math.ceil(duration * 30),
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Alternative
|
|
122
|
+
|
|
123
|
+
If `<AnimatedImage>` does not work (only supported in Chrome and Firefox), you can use `<Gif>` from `@remotion/gif` instead.
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npx remotion add @remotion/gif # If project uses npm
|
|
127
|
+
bunx remotion add @remotion/gif # If project uses bun
|
|
128
|
+
yarn remotion add @remotion/gif # If project uses yarn
|
|
129
|
+
pnpm exec remotion add @remotion/gif # If project uses pnpm
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import { Gif } from "@remotion/gif";
|
|
134
|
+
import { staticFile } from "remotion";
|
|
135
|
+
|
|
136
|
+
export const MyComposition = () => {
|
|
137
|
+
return <Gif src={staticFile("animation.gif")} width={500} height={500} />;
|
|
138
|
+
};
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The `<Gif>` component has the same props as `<AnimatedImage>` but only supports GIF files.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: images
|
|
3
|
+
description: Embedding images in Remotion using the <Img> component
|
|
4
|
+
metadata:
|
|
5
|
+
tags: images, img, staticFile, png, jpg, svg, webp
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Using images in Remotion
|
|
9
|
+
|
|
10
|
+
## The `<Img>` component
|
|
11
|
+
|
|
12
|
+
Always use the `<Img>` component from `remotion` to display images:
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Img, staticFile } from "remotion";
|
|
16
|
+
|
|
17
|
+
export const MyComposition = () => {
|
|
18
|
+
return <Img src={staticFile("photo.png")} />;
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Important restrictions
|
|
23
|
+
|
|
24
|
+
**You MUST use the `<Img>` component from `remotion`.** Do not use:
|
|
25
|
+
|
|
26
|
+
- Native HTML `<img>` elements
|
|
27
|
+
- Next.js `<Image>` component
|
|
28
|
+
- CSS `background-image`
|
|
29
|
+
|
|
30
|
+
The `<Img>` component ensures images are fully loaded before rendering, preventing flickering and blank frames during video export.
|
|
31
|
+
|
|
32
|
+
## Local images with staticFile()
|
|
33
|
+
|
|
34
|
+
Place images in the `public/` folder and use `staticFile()` to reference them:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
my-video/
|
|
38
|
+
├─ public/
|
|
39
|
+
│ ├─ logo.png
|
|
40
|
+
│ ├─ avatar.jpg
|
|
41
|
+
│ └─ icon.svg
|
|
42
|
+
├─ src/
|
|
43
|
+
├─ package.json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { Img, staticFile } from "remotion";
|
|
48
|
+
|
|
49
|
+
<Img src={staticFile("logo.png")} />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Remote images
|
|
53
|
+
|
|
54
|
+
Remote URLs can be used directly without `staticFile()`:
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<Img src="https://example.com/image.png" />
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Ensure remote images have CORS enabled.
|
|
61
|
+
|
|
62
|
+
For animated GIFs, use the `<Gif>` component from `@remotion/gif` instead.
|
|
63
|
+
|
|
64
|
+
## Sizing and positioning
|
|
65
|
+
|
|
66
|
+
Use the `style` prop to control size and position:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
<Img
|
|
70
|
+
src={staticFile("photo.png")}
|
|
71
|
+
style={{
|
|
72
|
+
width: 500,
|
|
73
|
+
height: 300,
|
|
74
|
+
position: "absolute",
|
|
75
|
+
top: 100,
|
|
76
|
+
left: 50,
|
|
77
|
+
objectFit: "cover",
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Dynamic image paths
|
|
83
|
+
|
|
84
|
+
Use template literals for dynamic file references:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
import { Img, staticFile, useCurrentFrame } from "remotion";
|
|
88
|
+
|
|
89
|
+
const frame = useCurrentFrame();
|
|
90
|
+
|
|
91
|
+
// Image sequence
|
|
92
|
+
<Img src={staticFile(`frames/frame${frame}.png`)} />
|
|
93
|
+
|
|
94
|
+
// Selecting based on props
|
|
95
|
+
<Img src={staticFile(`avatars/${props.userId}.png`)} />
|
|
96
|
+
|
|
97
|
+
// Conditional images
|
|
98
|
+
<Img src={staticFile(`icons/${isActive ? "active" : "inactive"}.svg`)} />
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This pattern is useful for:
|
|
102
|
+
|
|
103
|
+
- Image sequences (frame-by-frame animations)
|
|
104
|
+
- User-specific avatars or profile images
|
|
105
|
+
- Theme-based icons
|
|
106
|
+
- State-dependent graphics
|
|
107
|
+
|
|
108
|
+
## Getting image dimensions
|
|
109
|
+
|
|
110
|
+
Use `getImageDimensions()` to get the dimensions of an image:
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { getImageDimensions, staticFile } from "remotion";
|
|
114
|
+
|
|
115
|
+
const { width, height } = await getImageDimensions(staticFile("photo.png"));
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This is useful for calculating aspect ratios or sizing compositions:
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { getImageDimensions, staticFile, CalculateMetadataFunction } from "remotion";
|
|
122
|
+
|
|
123
|
+
const calculateMetadata: CalculateMetadataFunction = async () => {
|
|
124
|
+
const { width, height } = await getImageDimensions(staticFile("photo.png"));
|
|
125
|
+
return {
|
|
126
|
+
width,
|
|
127
|
+
height,
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: import-srt-captions
|
|
3
|
+
description: Importing .srt subtitle files into Remotion using @remotion/captions
|
|
4
|
+
metadata:
|
|
5
|
+
tags: captions, subtitles, srt, import, parse
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Importing .srt subtitles into Remotion
|
|
9
|
+
|
|
10
|
+
If you have an existing `.srt` subtitle file, you can import it into Remotion using `parseSrt()` from `@remotion/captions`.
|
|
11
|
+
|
|
12
|
+
If you don't have a .srt file, read [Transcribing audio](transcribe-captions.md) for how to generate captions instead.
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
First, the @remotion/captions package needs to be installed.
|
|
17
|
+
If it is not installed, use the following command:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx remotion add @remotion/captions # If project uses npm
|
|
21
|
+
bunx remotion add @remotion/captions # If project uses bun
|
|
22
|
+
yarn remotion add @remotion/captions # If project uses yarn
|
|
23
|
+
pnpm exec remotion add @remotion/captions # If project uses pnpm
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Reading an .srt file
|
|
27
|
+
|
|
28
|
+
Use `staticFile()` to reference an `.srt` file in your `public` folder, then fetch and parse it:
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { useState, useEffect, useCallback } from "react";
|
|
32
|
+
import { AbsoluteFill, staticFile, useDelayRender } from "remotion";
|
|
33
|
+
import { parseSrt } from "@remotion/captions";
|
|
34
|
+
import type { Caption } from "@remotion/captions";
|
|
35
|
+
|
|
36
|
+
export const MyComponent: React.FC = () => {
|
|
37
|
+
const [captions, setCaptions] = useState<Caption[] | null>(null);
|
|
38
|
+
const { delayRender, continueRender, cancelRender } = useDelayRender();
|
|
39
|
+
const [handle] = useState(() => delayRender());
|
|
40
|
+
|
|
41
|
+
const fetchCaptions = useCallback(async () => {
|
|
42
|
+
try {
|
|
43
|
+
const response = await fetch(staticFile("subtitles.srt"));
|
|
44
|
+
const text = await response.text();
|
|
45
|
+
const { captions: parsed } = parseSrt({ input: text });
|
|
46
|
+
setCaptions(parsed);
|
|
47
|
+
continueRender(handle);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
cancelRender(e);
|
|
50
|
+
}
|
|
51
|
+
}, [continueRender, cancelRender, handle]);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
fetchCaptions();
|
|
55
|
+
}, [fetchCaptions]);
|
|
56
|
+
|
|
57
|
+
if (!captions) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return <AbsoluteFill>{/* Use captions here */}</AbsoluteFill>;
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Remote URLs are also supported - you can `fetch()` a remote file via URL instead of using `staticFile()`.
|
|
66
|
+
|
|
67
|
+
## Using imported captions
|
|
68
|
+
|
|
69
|
+
Once parsed, the captions are in the `Caption` format and can be used with all `@remotion/captions` utilities.
|