🎥 Make videos programmatically with React
awesome
JonnyBurger934fddd0875b
diff --git a/packages/convert/app/components/get-supported-configs.tsx b/packages/convert/app/components/get-supported-configs.tsxindex e5d37e7f8d..b2a560e7bf 100644--- a/packages/convert/app/components/get-supported-configs.tsx+++ b/packages/convert/app/components/get-supported-configs.tsx@@ -70,6 +70,14 @@ const shouldPrioritizeVideoCopyOverReencode = (routeAction: RouteAction) => {return false;}+ if (routeAction.type === 'generic-crop') {+ return false;+ }++ if (routeAction.type === 'crop-format') {+ return false;+ }+throw new Error('Unsupported route action' + (routeAction satisfies never));};diff --git a/packages/convert/app/lib/default-ui.ts b/packages/convert/app/lib/default-ui.tsindex 5b3b75d59d..416972a12d 100644--- a/packages/convert/app/lib/default-ui.ts+++ b/packages/convert/app/lib/default-ui.ts@@ -49,6 +49,14 @@ export const defaultRotateOrMirorState = (return null;}+ if (action.type === 'generic-crop') {+ return 'crop';+ }++ if (action.type === 'crop-format') {+ return 'crop';+ }+throw new Error('Rotate is not enabled by default ' + (action satisfies never),);@@ -99,6 +107,14 @@ export const isConvertEnabledByDefault = (action: RouteAction) => {return true;}+ if (action.type === 'generic-crop') {+ return true;+ }++ if (action.type === 'crop-format') {+ return true;+ }+throw new Error('Convert is not enabled by default ' + (action satisfies never),);@@ -115,6 +131,17 @@ export type ConvertSections =export const getOrderOfSections = (action: RouteAction,): {[key in ConvertSections]: number} => {+ if (action.type === 'generic-crop' || action.type === 'crop-format') {+ return {+ crop: 0,+ resize: 1,+ rotate: 2,+ mirror: 3,+ convert: 4,+ resample: 5,+ };+ }+if (action.type === 'generic-rotate' || action.type === 'rotate-format') {return {rotate: 0,diff --git a/packages/convert/app/routes/crop.$format.tsx b/packages/convert/app/routes/crop.$format.tsxnew file mode 100644index 0000000000..67dffa87aa--- /dev/null+++ b/packages/convert/app/routes/crop.$format.tsx@@ -0,0 +1,19 @@+import {useParams} from '@remix-run/react';+import {useMemo} from 'react';+import {Main} from '~/components/Main';+import type {InputContainer, RouteAction} from '~/seo';++const Index = () => {+ const format = useParams().format as InputContainer;++ const routeAction: RouteAction = useMemo(() => {+ return {+ type: 'crop-format',+ format,+ };+ }, [format]);++ return <Main routeAction={routeAction} />;+};++export default Index;diff --git a/packages/convert/app/routes/crop._index.tsx b/packages/convert/app/routes/crop._index.tsxnew file mode 100644index 0000000000..aedf38ddb9--- /dev/null+++ b/packages/convert/app/routes/crop._index.tsx@@ -0,0 +1,12 @@+import {Main} from '~/components/Main';+import type {RouteAction} from '~/seo';++const action: RouteAction = {+ type: 'generic-crop',+};++const Index = () => {+ return <Main routeAction={action} />;+};++export default Index;diff --git a/packages/convert/app/routes/mirror.$format.tsx b/packages/convert/app/routes/mirror.$format.tsxindex a84b783444..a1a90e128a 100644--- a/packages/convert/app/routes/mirror.$format.tsx+++ b/packages/convert/app/routes/mirror.$format.tsx@@ -1,10 +1,10 @@import {useParams} from '@remix-run/react';import {useMemo} from 'react';import {Main} from '~/components/Main';-import type {OutputContainer, RouteAction} from '~/seo';+import type {InputContainer, RouteAction} from '~/seo';const Index = () => {- const format = useParams().format as OutputContainer;+ const format = useParams().format as InputContainer;const routeAction: RouteAction = useMemo(() => {return {diff --git a/packages/convert/app/routes/rotate.$format.tsx b/packages/convert/app/routes/rotate.$format.tsxindex 6b17bd80ef..e63917e012 100644--- a/packages/convert/app/routes/rotate.$format.tsx+++ b/packages/convert/app/routes/rotate.$format.tsx@@ -1,10 +1,10 @@import {useParams} from '@remix-run/react';import {useMemo} from 'react';import {Main} from '~/components/Main';-import type {OutputContainer, RouteAction} from '~/seo';+import type {InputContainer, RouteAction} from '~/seo';const Index = () => {- const format = useParams().format as OutputContainer;+ const format = useParams().format as InputContainer;const routeAction: RouteAction = useMemo(() => {return {diff --git a/packages/convert/app/seo.ts b/packages/convert/app/seo.tsindex 288ddb5545..02703501ed 100644--- a/packages/convert/app/seo.ts+++ b/packages/convert/app/seo.ts@@ -44,14 +44,21 @@ export type RouteAction =}| {type: 'rotate-format';- format: OutputContainer;+ format: InputContainer;}| {type: 'generic-mirror';}| {type: 'mirror-format';- format: OutputContainer;+ format: InputContainer;+ }+ | {+ type: 'generic-crop';+ }+ | {+ type: 'crop-format';+ format: InputContainer;}| {type: 'generic-resize';@@ -115,6 +122,14 @@ export const getHeaderTitle = (routeAction: RouteAction) => {return 'Fast video and audio transcription in the browser';}+ if (routeAction.type === 'generic-crop') {+ return 'Fast video cropping in the browser';+ }++ if (routeAction.type === 'crop-format') {+ return `Fast ${renderHumanReadableContainer(routeAction.format)} cropping in the browser`;+ }+throw new Error(`Invalid route action ${routeAction satisfies never}`);};@@ -163,6 +178,14 @@ export const getPageTitle = (routeAction: RouteAction) => {return `Online Audio and Video Transcriber - Remotion Convert`;}+ if (routeAction.type === 'generic-crop') {+ return 'Online Video Cropper - Remotion Convert';+ }++ if (routeAction.type === 'crop-format') {+ return `Online ${renderHumanReadableContainer(routeAction.format)} Cropper - Remotion Convert`;+ }+throw new Error(`Invalid route action ${routeAction satisfies never}`);};@@ -217,6 +240,14 @@ export const getDescription = (routeAction: RouteAction) => {return `A free and local online audio and video transcriber, powered by Whisper. No upload required, no watermarks, no limits.`;}+ if (routeAction.type === 'generic-crop') {+ return `The fastest online video cropper, powered by WebCodecs. No upload required, no watermarks, no limits.`;+ }++ if (routeAction.type === 'crop-format') {+ return `The fastest online ${renderHumanReadableContainer(routeAction.format)} cropper, powered by WebCodecs. No upload required, no watermarks, no limits.`;+ }+throw new Error(`Invalid route action ${routeAction satisfies never}`);};@@ -265,5 +296,13 @@ export const makeSlug = (routeAction: RouteAction) => {return '/transcribe';}+ if (routeAction.type === 'generic-crop') {+ return '/crop';+ }++ if (routeAction.type === 'crop-format') {+ return `/crop/${routeAction.format}`;+ }+throw new Error(`Invalid route action ${routeAction satisfies never}`);};diff --git a/packages/docs/copy-convert.ts b/packages/docs/copy-convert.tsindex 14cf17d1b6..c6f9882f1f 100644--- a/packages/docs/copy-convert.ts+++ b/packages/docs/copy-convert.ts@@ -35,6 +35,11 @@ for (const inputs of seo.inputContainers) {format: inputs,});+ extraPages.push({+ type: 'crop-format',+ format: inputs,+ });+extraPages.push({type: 'resize-format',format: inputs,@@ -78,6 +83,10 @@ extraPages.push({type: 'generic-mirror',});+extraPages.push({+ type: 'generic-crop',+});+extraPages.push({type: 'generic-probe',});