@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,198 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: audio-visualization
|
|
3
|
+
description: Audio visualization patterns - spectrum bars, waveforms, bass-reactive effects
|
|
4
|
+
metadata:
|
|
5
|
+
tags: audio, visualization, spectrum, waveform, bass, music, audiogram, frequency
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Audio Visualization in Remotion
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npx remotion add @remotion/media-utils
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Loading Audio Data
|
|
17
|
+
|
|
18
|
+
Use `useWindowedAudioData()` (https://www.remotion.dev/docs/use-windowed-audio-data) to load audio data:
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { useWindowedAudioData } from "@remotion/media-utils";
|
|
22
|
+
import { staticFile, useCurrentFrame, useVideoConfig } from "remotion";
|
|
23
|
+
|
|
24
|
+
const frame = useCurrentFrame();
|
|
25
|
+
const { fps } = useVideoConfig();
|
|
26
|
+
|
|
27
|
+
const { audioData, dataOffsetInSeconds } = useWindowedAudioData({
|
|
28
|
+
src: staticFile("podcast.wav"),
|
|
29
|
+
frame,
|
|
30
|
+
fps,
|
|
31
|
+
windowInSeconds: 30,
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Spectrum Bar Visualization
|
|
36
|
+
|
|
37
|
+
Use `visualizeAudio()` (https://www.remotion.dev/docs/visualize-audio) to get frequency data for bar charts:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { useWindowedAudioData, visualizeAudio } from "@remotion/media-utils";
|
|
41
|
+
import { staticFile, useCurrentFrame, useVideoConfig } from "remotion";
|
|
42
|
+
|
|
43
|
+
const frame = useCurrentFrame();
|
|
44
|
+
const { fps } = useVideoConfig();
|
|
45
|
+
|
|
46
|
+
const { audioData, dataOffsetInSeconds } = useWindowedAudioData({
|
|
47
|
+
src: staticFile("music.mp3"),
|
|
48
|
+
frame,
|
|
49
|
+
fps,
|
|
50
|
+
windowInSeconds: 30,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (!audioData) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const frequencies = visualizeAudio({
|
|
58
|
+
fps,
|
|
59
|
+
frame,
|
|
60
|
+
audioData,
|
|
61
|
+
numberOfSamples: 256,
|
|
62
|
+
optimizeFor: "speed",
|
|
63
|
+
dataOffsetInSeconds,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div style={{ display: "flex", alignItems: "flex-end", height: 200 }}>
|
|
68
|
+
{frequencies.map((v, i) => (
|
|
69
|
+
<div
|
|
70
|
+
key={i}
|
|
71
|
+
style={{
|
|
72
|
+
flex: 1,
|
|
73
|
+
height: `${v * 100}%`,
|
|
74
|
+
backgroundColor: "#0b84f3",
|
|
75
|
+
margin: "0 1px",
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
))}
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- `numberOfSamples` must be power of 2 (32, 64, 128, 256, 512, 1024)
|
|
84
|
+
- Values range 0-1; left of array = bass, right = highs
|
|
85
|
+
- Use `optimizeFor: "speed"` for Lambda or high sample counts
|
|
86
|
+
|
|
87
|
+
**Important:** When passing `audioData` to child components, also pass the `frame` from the parent. Do not call `useCurrentFrame()` in each child - this causes discontinuous visualization when children are inside `<Sequence>` with offsets.
|
|
88
|
+
|
|
89
|
+
## Waveform Visualization
|
|
90
|
+
|
|
91
|
+
Use `visualizeAudioWaveform()` (https://www.remotion.dev/docs/media-utils/visualize-audio-waveform) with `createSmoothSvgPath()` (https://www.remotion.dev/docs/media-utils/create-smooth-svg-path) for oscilloscope-style displays:
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import {
|
|
95
|
+
createSmoothSvgPath,
|
|
96
|
+
useWindowedAudioData,
|
|
97
|
+
visualizeAudioWaveform,
|
|
98
|
+
} from "@remotion/media-utils";
|
|
99
|
+
import { staticFile, useCurrentFrame, useVideoConfig } from "remotion";
|
|
100
|
+
|
|
101
|
+
const frame = useCurrentFrame();
|
|
102
|
+
const { width, fps } = useVideoConfig();
|
|
103
|
+
const HEIGHT = 200;
|
|
104
|
+
|
|
105
|
+
const { audioData, dataOffsetInSeconds } = useWindowedAudioData({
|
|
106
|
+
src: staticFile("voice.wav"),
|
|
107
|
+
frame,
|
|
108
|
+
fps,
|
|
109
|
+
windowInSeconds: 30,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
if (!audioData) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const waveform = visualizeAudioWaveform({
|
|
117
|
+
fps,
|
|
118
|
+
frame,
|
|
119
|
+
audioData,
|
|
120
|
+
numberOfSamples: 256,
|
|
121
|
+
windowInSeconds: 0.5,
|
|
122
|
+
dataOffsetInSeconds,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const path = createSmoothSvgPath({
|
|
126
|
+
points: waveform.map((y, i) => ({
|
|
127
|
+
x: (i / (waveform.length - 1)) * width,
|
|
128
|
+
y: HEIGHT / 2 + (y * HEIGHT) / 2,
|
|
129
|
+
})),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<svg width={width} height={HEIGHT}>
|
|
134
|
+
<path d={path} fill="none" stroke="#0b84f3" strokeWidth={2} />
|
|
135
|
+
</svg>
|
|
136
|
+
);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Bass-Reactive Effects
|
|
140
|
+
|
|
141
|
+
Extract low frequencies for beat-reactive animations:
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
const frequencies = visualizeAudio({
|
|
145
|
+
fps,
|
|
146
|
+
frame,
|
|
147
|
+
audioData,
|
|
148
|
+
numberOfSamples: 128,
|
|
149
|
+
optimizeFor: "speed",
|
|
150
|
+
dataOffsetInSeconds,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const lowFrequencies = frequencies.slice(0, 32);
|
|
154
|
+
const bassIntensity =
|
|
155
|
+
lowFrequencies.reduce((sum, v) => sum + v, 0) / lowFrequencies.length;
|
|
156
|
+
|
|
157
|
+
const scale = 1 + bassIntensity * 0.5;
|
|
158
|
+
const opacity = Math.min(0.6, bassIntensity * 0.8);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Volume-Based Waveform
|
|
162
|
+
|
|
163
|
+
Use `getWaveformPortion()` (https://www.remotion.dev/docs/get-waveform-portion) when you need simplified volume data instead of frequency spectrum:
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import { getWaveformPortion } from "@remotion/media-utils";
|
|
167
|
+
import { useCurrentFrame, useVideoConfig } from "remotion";
|
|
168
|
+
|
|
169
|
+
const frame = useCurrentFrame();
|
|
170
|
+
const { fps } = useVideoConfig();
|
|
171
|
+
const currentTimeInSeconds = frame / fps;
|
|
172
|
+
|
|
173
|
+
const waveform = getWaveformPortion({
|
|
174
|
+
audioData,
|
|
175
|
+
startTimeInSeconds: currentTimeInSeconds,
|
|
176
|
+
durationInSeconds: 5,
|
|
177
|
+
numberOfSamples: 50,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Returns array of { index, amplitude } objects (amplitude: 0-1)
|
|
181
|
+
waveform.map((bar) => (
|
|
182
|
+
<div key={bar.index} style={{ height: bar.amplitude * 100 }} />
|
|
183
|
+
));
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Postprocessing
|
|
187
|
+
|
|
188
|
+
Low frequencies naturally dominate. Apply logarithmic scaling for visual balance:
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
const minDb = -100;
|
|
192
|
+
const maxDb = -30;
|
|
193
|
+
|
|
194
|
+
const scaled = frequencies.map((value) => {
|
|
195
|
+
const db = 20 * Math.log10(value);
|
|
196
|
+
return (db - minDb) / (maxDb - minDb);
|
|
197
|
+
});
|
|
198
|
+
```
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: audio
|
|
3
|
+
description: Using audio and sound in Remotion - importing, trimming, volume, speed, pitch
|
|
4
|
+
metadata:
|
|
5
|
+
tags: audio, media, trim, volume, speed, loop, pitch, mute, sound, sfx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Using audio in Remotion
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
First, the @remotion/media package needs to be installed.
|
|
13
|
+
If it is not installed, use the following command:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx remotion add @remotion/media
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Importing Audio
|
|
20
|
+
|
|
21
|
+
Use `<Audio>` from `@remotion/media` to add audio to your composition.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Audio } from "@remotion/media";
|
|
25
|
+
import { staticFile } from "remotion";
|
|
26
|
+
|
|
27
|
+
export const MyComposition = () => {
|
|
28
|
+
return <Audio src={staticFile("audio.mp3")} />;
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Remote URLs are also supported:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
<Audio src="https://remotion.media/audio.mp3" />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
By default, audio plays from the start, at full volume and full length.
|
|
39
|
+
Multiple audio tracks can be layered by adding multiple `<Audio>` components.
|
|
40
|
+
|
|
41
|
+
## Trimming
|
|
42
|
+
|
|
43
|
+
Use `trimBefore` and `trimAfter` to remove portions of the audio. Values are in frames.
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
const { fps } = useVideoConfig();
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Audio
|
|
50
|
+
src={staticFile("audio.mp3")}
|
|
51
|
+
trimBefore={2 * fps} // Skip the first 2 seconds
|
|
52
|
+
trimAfter={10 * fps} // End at the 10 second mark
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The audio still starts playing at the beginning of the composition - only the specified portion is played.
|
|
58
|
+
|
|
59
|
+
## Delaying
|
|
60
|
+
|
|
61
|
+
Wrap the audio in a `<Sequence>` to delay when it starts:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Sequence, staticFile } from "remotion";
|
|
65
|
+
import { Audio } from "@remotion/media";
|
|
66
|
+
|
|
67
|
+
const { fps } = useVideoConfig();
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Sequence from={1 * fps}>
|
|
71
|
+
<Audio src={staticFile("audio.mp3")} />
|
|
72
|
+
</Sequence>
|
|
73
|
+
);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The audio will start playing after 1 second.
|
|
77
|
+
|
|
78
|
+
## Volume
|
|
79
|
+
|
|
80
|
+
Set a static volume (0 to 1):
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<Audio src={staticFile("audio.mp3")} volume={0.5} />
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Or use a callback for dynamic volume based on the current frame:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { interpolate } from "remotion";
|
|
90
|
+
|
|
91
|
+
const { fps } = useVideoConfig();
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Audio
|
|
95
|
+
src={staticFile("audio.mp3")}
|
|
96
|
+
volume={(f) =>
|
|
97
|
+
interpolate(f, [0, 1 * fps], [0, 1], { extrapolateRight: "clamp" })
|
|
98
|
+
}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The value of `f` starts at 0 when the audio begins to play, not the composition frame.
|
|
104
|
+
|
|
105
|
+
## Muting
|
|
106
|
+
|
|
107
|
+
Use `muted` to silence the audio. It can be set dynamically:
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
const frame = useCurrentFrame();
|
|
111
|
+
const { fps } = useVideoConfig();
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<Audio
|
|
115
|
+
src={staticFile("audio.mp3")}
|
|
116
|
+
muted={frame >= 2 * fps && frame <= 4 * fps} // Mute between 2s and 4s
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Speed
|
|
122
|
+
|
|
123
|
+
Use `playbackRate` to change the playback speed:
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
<Audio src={staticFile("audio.mp3")} playbackRate={2} /> {/* 2x speed */}
|
|
127
|
+
<Audio src={staticFile("audio.mp3")} playbackRate={0.5} /> {/* Half speed */}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Reverse playback is not supported.
|
|
131
|
+
|
|
132
|
+
## Looping
|
|
133
|
+
|
|
134
|
+
Use `loop` to loop the audio indefinitely:
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
<Audio src={staticFile("audio.mp3")} loop />
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Use `loopVolumeCurveBehavior` to control how the frame count behaves when looping:
|
|
141
|
+
|
|
142
|
+
- `"repeat"`: Frame count resets to 0 each loop (default)
|
|
143
|
+
- `"extend"`: Frame count continues incrementing
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
<Audio
|
|
147
|
+
src={staticFile("audio.mp3")}
|
|
148
|
+
loop
|
|
149
|
+
loopVolumeCurveBehavior="extend"
|
|
150
|
+
volume={(f) => interpolate(f, [0, 300], [1, 0])} // Fade out over multiple loops
|
|
151
|
+
/>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Pitch
|
|
155
|
+
|
|
156
|
+
Use `toneFrequency` to adjust the pitch without affecting speed. Values range from 0.01 to 2:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<Audio
|
|
160
|
+
src={staticFile("audio.mp3")}
|
|
161
|
+
toneFrequency={1.5} // Higher pitch
|
|
162
|
+
/>
|
|
163
|
+
<Audio
|
|
164
|
+
src={staticFile("audio.mp3")}
|
|
165
|
+
toneFrequency={0.8} // Lower pitch
|
|
166
|
+
/>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Pitch shifting only works during server-side rendering, not in the Remotion Studio preview or in the `<Player />`.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: calculate-metadata
|
|
3
|
+
description: Dynamically set composition duration, dimensions, and props
|
|
4
|
+
metadata:
|
|
5
|
+
tags: calculateMetadata, duration, dimensions, props, dynamic
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Using calculateMetadata
|
|
9
|
+
|
|
10
|
+
Use `calculateMetadata` on a `<Composition>` to dynamically set duration, dimensions, and transform props before rendering.
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
<Composition id="MyComp" component={MyComponent} durationInFrames={300} fps={30} width={1920} height={1080} defaultProps={{videoSrc: 'https://remotion.media/video.mp4'}} calculateMetadata={calculateMetadata} />
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Setting duration based on a video
|
|
17
|
+
|
|
18
|
+
Use the `getMediaMetadata()` function from the mediabunny/metadata skill to get the video duration:
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import {CalculateMetadataFunction} from 'remotion';
|
|
22
|
+
import {getMediaMetadata} from '../get-media-metadata';
|
|
23
|
+
|
|
24
|
+
const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
|
|
25
|
+
const {durationInSeconds} = await getMediaMetadata(props.videoSrc);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
durationInFrames: Math.ceil(durationInSeconds * 30),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Matching dimensions of a video
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
|
|
37
|
+
const {durationInSeconds, dimensions} = await getMediaMetadata(props.videoSrc);
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
durationInFrames: Math.ceil(durationInSeconds * 30),
|
|
41
|
+
width: dimensions?.width ?? 1920,
|
|
42
|
+
height: dimensions?.height ?? 1080,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Setting duration based on multiple videos
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
|
|
51
|
+
const metadataPromises = props.videos.map((video) => getMediaMetadata(video.src));
|
|
52
|
+
const allMetadata = await Promise.all(metadataPromises);
|
|
53
|
+
|
|
54
|
+
const totalDuration = allMetadata.reduce((sum, meta) => sum + meta.durationInSeconds, 0);
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
durationInFrames: Math.ceil(totalDuration * 30),
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Setting a default outName
|
|
63
|
+
|
|
64
|
+
Set the default output filename based on props:
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
const calculateMetadata: CalculateMetadataFunction<Props> = async ({props}) => {
|
|
68
|
+
return {
|
|
69
|
+
defaultOutName: `video-${props.id}.mp4`,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Transforming props
|
|
75
|
+
|
|
76
|
+
Fetch data or transform props before rendering:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
const calculateMetadata: CalculateMetadataFunction<Props> = async ({props, abortSignal}) => {
|
|
80
|
+
const response = await fetch(props.dataUrl, {signal: abortSignal});
|
|
81
|
+
const data = await response.json();
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
props: {
|
|
85
|
+
...props,
|
|
86
|
+
fetchedData: data,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The `abortSignal` cancels stale requests when props change in the Studio.
|
|
93
|
+
|
|
94
|
+
## Return value
|
|
95
|
+
|
|
96
|
+
All fields are optional. Returned values override the `<Composition>` props:
|
|
97
|
+
|
|
98
|
+
- `durationInFrames`: Number of frames
|
|
99
|
+
- `width`: Composition width in pixels
|
|
100
|
+
- `height`: Composition height in pixels
|
|
101
|
+
- `fps`: Frames per second
|
|
102
|
+
- `props`: Transformed props passed to the component
|
|
103
|
+
- `defaultOutName`: Default output filename
|
|
104
|
+
- `defaultCodec`: Default codec for rendering
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: can-decode
|
|
3
|
+
description: Check if a video can be decoded by the browser using Mediabunny
|
|
4
|
+
metadata:
|
|
5
|
+
tags: decode, validation, video, audio, compatibility, browser
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Checking if a video can be decoded
|
|
9
|
+
|
|
10
|
+
Use Mediabunny to check if a video can be decoded by the browser before attempting to play it.
|
|
11
|
+
|
|
12
|
+
## The `canDecode()` function
|
|
13
|
+
|
|
14
|
+
This function can be copy-pasted into any project.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { Input, ALL_FORMATS, UrlSource } from "mediabunny";
|
|
18
|
+
|
|
19
|
+
export const canDecode = async (src: string) => {
|
|
20
|
+
const input = new Input({
|
|
21
|
+
formats: ALL_FORMATS,
|
|
22
|
+
source: new UrlSource(src, {
|
|
23
|
+
getRetryDelay: () => null,
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
await input.getFormat();
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const videoTrack = await input.getPrimaryVideoTrack();
|
|
34
|
+
if (videoTrack && !(await videoTrack.canDecode())) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const audioTrack = await input.getPrimaryAudioTrack();
|
|
39
|
+
if (audioTrack && !(await audioTrack.canDecode())) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
const src = "https://remotion.media/video.mp4";
|
|
51
|
+
const isDecodable = await canDecode(src);
|
|
52
|
+
|
|
53
|
+
if (isDecodable) {
|
|
54
|
+
console.log("Video can be decoded");
|
|
55
|
+
} else {
|
|
56
|
+
console.log("Video cannot be decoded by this browser");
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Using with Blob
|
|
61
|
+
|
|
62
|
+
For file uploads or drag-and-drop, use `BlobSource`:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { Input, ALL_FORMATS, BlobSource } from "mediabunny";
|
|
66
|
+
|
|
67
|
+
export const canDecodeBlob = async (blob: Blob) => {
|
|
68
|
+
const input = new Input({
|
|
69
|
+
formats: ALL_FORMATS,
|
|
70
|
+
source: new BlobSource(blob),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Same validation logic as above
|
|
74
|
+
};
|
|
75
|
+
```
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: charts
|
|
3
|
+
description: Chart and data visualization patterns for Remotion. Use when creating bar charts, pie charts, line charts, stock graphs, or any data-driven animations.
|
|
4
|
+
metadata:
|
|
5
|
+
tags: charts, data, visualization, bar-chart, pie-chart, line-chart, stock-chart, svg-paths, graphs
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Charts in Remotion
|
|
9
|
+
|
|
10
|
+
Create charts using React code - HTML, SVG, and D3.js are all supported.
|
|
11
|
+
|
|
12
|
+
Disable all animations from third party libraries - they cause flickering.
|
|
13
|
+
Drive all animations from `useCurrentFrame()`.
|
|
14
|
+
|
|
15
|
+
## Bar Chart
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
const STAGGER_DELAY = 5;
|
|
19
|
+
const frame = useCurrentFrame();
|
|
20
|
+
const { fps } = useVideoConfig();
|
|
21
|
+
|
|
22
|
+
const bars = data.map((item, i) => {
|
|
23
|
+
const height = spring({
|
|
24
|
+
frame,
|
|
25
|
+
fps,
|
|
26
|
+
delay: i * STAGGER_DELAY,
|
|
27
|
+
config: { damping: 200 },
|
|
28
|
+
});
|
|
29
|
+
return <div style={{ height: height * item.value }} />;
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Pie Chart
|
|
34
|
+
|
|
35
|
+
Animate segments using stroke-dashoffset, starting from 12 o'clock:
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
const progress = interpolate(frame, [0, 100], [0, 1]);
|
|
39
|
+
const circumference = 2 * Math.PI * radius;
|
|
40
|
+
const segmentLength = (value / total) * circumference;
|
|
41
|
+
const offset = interpolate(progress, [0, 1], [segmentLength, 0]);
|
|
42
|
+
|
|
43
|
+
<circle
|
|
44
|
+
r={radius}
|
|
45
|
+
cx={center}
|
|
46
|
+
cy={center}
|
|
47
|
+
fill="none"
|
|
48
|
+
stroke={color}
|
|
49
|
+
strokeWidth={strokeWidth}
|
|
50
|
+
strokeDasharray={`${segmentLength} ${circumference}`}
|
|
51
|
+
strokeDashoffset={offset}
|
|
52
|
+
transform={`rotate(-90 ${center} ${center})`}
|
|
53
|
+
/>;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Line Chart / Path Animation
|
|
57
|
+
|
|
58
|
+
Use `@remotion/paths` for animating SVG paths (line charts, stock graphs, signatures).
|
|
59
|
+
|
|
60
|
+
Install: `npx remotion add @remotion/paths`
|
|
61
|
+
Docs: https://remotion.dev/docs/paths.md
|
|
62
|
+
|
|
63
|
+
### Convert data points to SVG path
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
type Point = { x: number; y: number };
|
|
67
|
+
|
|
68
|
+
const generateLinePath = (points: Point[]): string => {
|
|
69
|
+
if (points.length < 2) return "";
|
|
70
|
+
return points.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`).join(" ");
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Draw path with animation
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { evolvePath } from "@remotion/paths";
|
|
78
|
+
|
|
79
|
+
const path = "M 100 200 L 200 150 L 300 180 L 400 100";
|
|
80
|
+
const progress = interpolate(frame, [0, 2 * fps], [0, 1], {
|
|
81
|
+
extrapolateLeft: "clamp",
|
|
82
|
+
extrapolateRight: "clamp",
|
|
83
|
+
easing: Easing.out(Easing.quad),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const { strokeDasharray, strokeDashoffset } = evolvePath(progress, path);
|
|
87
|
+
|
|
88
|
+
<path
|
|
89
|
+
d={path}
|
|
90
|
+
fill="none"
|
|
91
|
+
stroke="#FF3232"
|
|
92
|
+
strokeWidth={4}
|
|
93
|
+
strokeDasharray={strokeDasharray}
|
|
94
|
+
strokeDashoffset={strokeDashoffset}
|
|
95
|
+
/>;
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Follow path with marker/arrow
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import {
|
|
102
|
+
getLength,
|
|
103
|
+
getPointAtLength,
|
|
104
|
+
getTangentAtLength,
|
|
105
|
+
} from "@remotion/paths";
|
|
106
|
+
|
|
107
|
+
const pathLength = getLength(path);
|
|
108
|
+
const point = getPointAtLength(path, progress * pathLength);
|
|
109
|
+
const tangent = getTangentAtLength(path, progress * pathLength);
|
|
110
|
+
const angle = Math.atan2(tangent.y, tangent.x);
|
|
111
|
+
|
|
112
|
+
<g
|
|
113
|
+
style={{
|
|
114
|
+
transform: `translate(${point.x}px, ${point.y}px) rotate(${angle}rad)`,
|
|
115
|
+
transformOrigin: "0 0",
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
<polygon points="0,0 -20,-10 -20,10" fill="#FF3232" />
|
|
119
|
+
</g>;
|
|
120
|
+
```
|