🎥 Make videos programmatically with React
progress the whole thing
Jonny Burger1f390939eadc
diff --git a/packages/captions/src/captions.ts b/packages/captions/src/captions.tsindex ae7c9cb806..63d333b34c 100644--- a/packages/captions/src/captions.ts+++ b/packages/captions/src/captions.ts@@ -1,6 +1,7 @@export type Caption = {text: string;- timestamp: number;+ timestampMs: number | null;startMs: number;endMs: number;+ confidence: number | null;};diff --git a/packages/docs/components/TableOfContents/api.tsx b/packages/docs/components/TableOfContents/api.tsxindex f5a5c66d4e..7975ecb321 100644--- a/packages/docs/components/TableOfContents/api.tsx+++ b/packages/docs/components/TableOfContents/api.tsx@@ -44,6 +44,10 @@ export const TableOfContents: React.FC = () => {<strong>@remotion/cloudrun</strong><div>Render videos and stills on GCP Cloud Run</div></TOCItem>+ <TOCItem link="/docs/captions">+ <strong>@remotion/captions</strong>+ <div>Common operations for subtitles</div>+ </TOCItem><TOCItem link="/docs/gif"><strong>@remotion/gif</strong><div>Include a GIF in your video</div>diff --git a/packages/docs/docs/captions/TableOfContents.tsx b/packages/docs/docs/captions/TableOfContents.tsxnew file mode 100644index 0000000000..1dfa15f259--- /dev/null+++ b/packages/docs/docs/captions/TableOfContents.tsx@@ -0,0 +1,16 @@+import React from 'react';+import {Grid} from '../../components/TableOfContents/Grid';+import {TOCItem} from '../../components/TableOfContents/TOCItem';++export const TableOfContents: React.FC = () => {+ return (+ <div>+ <Grid>+ <TOCItem link="/docs/captions/create-tiktok-style-captions">+ <strong>{'createTikTokStyleCaptions()'}</strong>+ <div>Structure the captions for TikTok-style display</div>+ </TOCItem>+ </Grid>+ </div>+ );+};diff --git a/packages/docs/docs/captions/index.mdx b/packages/docs/docs/captions/index.mdxnew file mode 100644index 0000000000..5e871a6d14--- /dev/null+++ b/packages/docs/docs/captions/index.mdx@@ -0,0 +1,22 @@+---+title: '@remotion/captions'+crumb: 'Subtitle videos'+---++_Available from v4.0.216_++The `@remotion/captions` package provides utilities for dealing with subtitles.++Captions generated from `@remotion/install-whisper-cpp` and other providers can be converted into a format that is compatible with the `@remotion/captions` format.++import {TableOfContents} from './TableOfContents';++<Installation pkg="@remotion/captions" />++## Functions++<TableOfContents />++## License++MITdiff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex c2987eca04..672986f3cf 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -567,6 +567,15 @@ module.exports = {'media-parser/support',],},+ {+ type: 'category',+ label: '@remotion/captions',+ link: {+ type: 'doc',+ id: 'captions/index',+ },+ items: [],+ },{type: 'category',label: '@remotion/install-whisper-cpp',diff --git a/packages/install-whisper-cpp/src/convert.ts b/packages/install-whisper-cpp/src/convert.tsindex 1566aefadd..5cb24c21b6 100644--- a/packages/install-whisper-cpp/src/convert.ts+++ b/packages/install-whisper-cpp/src/convert.ts@@ -15,11 +15,17 @@ export const convert = (input: ConvertInput): ConvertOutput => {const captions: Caption[] = [];for (const item of transcription) {+ if (item.text === '') {+ continue;+ }+captions.push({- text: item.text,+ text: captions.length === 0 ? item.text.trimStart() : item.text,startMs: item.offsets.from,endMs: item.offsets.to,- timestamp: item.tokens[0].t_dtw * 10,+ timestampMs:+ item.tokens[0].t_dtw === -1 ? null : item.tokens[0].t_dtw * 10,+ confidence: item.tokens[0].p,});}diff --git a/packages/install-whisper-cpp/tsconfig.json b/packages/install-whisper-cpp/tsconfig.jsonindex a4c13aa211..c2d7ad2073 100644--- a/packages/install-whisper-cpp/tsconfig.json+++ b/packages/install-whisper-cpp/tsconfig.json@@ -1,8 +1,9 @@{- "extends": "../tsconfig.settings.json",- "compilerOptions": {- "rootDir": "src",- "outDir": "dist"- },- "include": ["src"]+ "extends": "../tsconfig.settings.json",+ "compilerOptions": {+ "rootDir": "src",+ "outDir": "dist"+ },+ "include": ["src"],+ "references": [{"path": "../captions"}]}