Skip to content

🎥 Make videos programmatically with React

/mirror

Jonny Burger5209f6fa2573
diff --git a/packages/convert/app/lib/default-ui.ts b/packages/convert/app/lib/default-ui.ts
index ca79214461..1b28666a27 100644
--- a/packages/convert/app/lib/default-ui.ts
+++ b/packages/convert/app/lib/default-ui.ts
@@ -21,6 +21,14 @@ export const defaultRotateOrMirorState = (
return 'rotate';
}
+ if (action.type === 'mirror-format') {
+ return 'mirror';
+ }
+
+ if (action.type === 'generic-mirror') {
+ return 'mirror';
+ }
+
throw new Error(
'Rotate is not enabled by default ' + (action satisfies never),
);
@@ -43,6 +51,14 @@ export const isConvertEnabledByDefault = (action: RouteAction) => {
return false;
}
+ if (action.type === 'mirror-format') {
+ return false;
+ }
+
+ if (action.type === 'generic-mirror') {
+ return false;
+ }
+
throw new Error(
'Convert is not enabled by default ' + (action satisfies never),
);
@@ -74,6 +90,20 @@ export const getOrderOfSections = (
mirror: 2,
};
}
+ if (action.type === 'generic-mirror') {
+ return {
+ mirror: 0,
+ rotate: 1,
+ convert: 2,
+ };
+ }
+ if (action.type === 'mirror-format') {
+ return {
+ mirror: 0,
+ rotate: 1,
+ convert: 2,
+ };
+ }
throw new Error(action satisfies never);
};
diff --git a/packages/convert/app/routes/mirror.$format.tsx b/packages/convert/app/routes/mirror.$format.tsx
new file mode 100644
index 0000000000..a2ad48c08e
--- /dev/null
+++ b/packages/convert/app/routes/mirror.$format.tsx
@@ -0,0 +1,20 @@
+import {useParams} from '@remix-run/react';
+import {ConvertMediaContainer} from '@remotion/webcodecs';
+import {useMemo} from 'react';
+import {Main} from '~/components/Main';
+import {RouteAction} from '~/seo';
+
+const Index = () => {
+ const format = useParams().format as ConvertMediaContainer;
+
+ const routeAction: RouteAction = useMemo(() => {
+ return {
+ type: 'mirror-format',
+ format,
+ };
+ }, [format]);
+
+ return <Main routeAction={routeAction} />;
+};
+
+export default Index;
diff --git a/packages/convert/app/routes/mirror._index.tsx b/packages/convert/app/routes/mirror._index.tsx
new file mode 100644
index 0000000000..8aa87b3e8e
--- /dev/null
+++ b/packages/convert/app/routes/mirror._index.tsx
@@ -0,0 +1,12 @@
+import {Main} from '~/components/Main';
+import {RouteAction} from '~/seo';
+
+const action: RouteAction = {
+ type: 'generic-mirror',
+};
+
+const Index = () => {
+ return <Main routeAction={action} />;
+};
+
+export default Index;
diff --git a/packages/convert/app/routes/test._index.tsx b/packages/convert/app/routes/test._index.tsx
index c8b2bee485..986c80980c 100644
--- a/packages/convert/app/routes/test._index.tsx
+++ b/packages/convert/app/routes/test._index.tsx
@@ -6,7 +6,7 @@ import {TestComponent} from '~/tests/TestComponent';
const TestSuite: React.FC = () => {
return (
<div className="bg-slate-50 min-h-screen w-screen">
- <div className="w-full max-w-[900px] pt-16 m-auto gap-4 flex flex-col px-5">
+ <div className="w-full max-w-[900px] pt-16 m-auto gap-4 flex flex-col px-5 pb-20">
<RunAll tests={testList} />
{testList.map((t) => {
return <TestComponent key={t.name} test={t} />;
diff --git a/packages/convert/app/seo.ts b/packages/convert/app/seo.ts
index d0a57cba24..8d7b541cd0 100644
--- a/packages/convert/app/seo.ts
+++ b/packages/convert/app/seo.ts
@@ -39,6 +39,13 @@ export type RouteAction =
| {
type: 'rotate-format';
format: ConvertMediaContainer;
+ }
+ | {
+ type: 'generic-mirror';
+ }
+ | {
+ type: 'mirror-format';
+ format: ConvertMediaContainer;
};
export const getHeaderTitle = (routeAction: RouteAction) => {
@@ -58,6 +65,14 @@ export const getHeaderTitle = (routeAction: RouteAction) => {
return `Fast ${renderHumanReadableContainer(routeAction.format)} rotation in the browser`;
}
+ if (routeAction.type === 'generic-mirror') {
+ return 'Fast video mirroring in the browser';
+ }
+
+ if (routeAction.type === 'mirror-format') {
+ return `Fast ${renderHumanReadableContainer(routeAction.format)} mirroring in the browser`;
+ }
+
throw new Error(`Invalid route action ${routeAction satisfies never}`);
};
@@ -74,10 +89,18 @@ export const getPageTitle = (routeAction: RouteAction) => {
return 'Online video Rotation - Remotion Convert';
}
+ if (routeAction.type === 'generic-mirror') {
+ return 'Online video Mirrorer - Remotion Convert';
+ }
+
if (routeAction.type === 'rotate-format') {
return `Online ${renderHumanReadableContainer(routeAction.format)} Rotator - Remotion Convert`;
}
+ if (routeAction.type === 'mirror-format') {
+ return `Online ${renderHumanReadableContainer(routeAction.format)} Mirrorer - Remotion Convert`;
+ }
+
throw new Error(`Invalid route action ${routeAction satisfies never}`);
};
@@ -94,12 +117,22 @@ export const getDescription = (routeAction: RouteAction) => {
return `The fastest online video rotator, powered by WebCodecs. No upload required, no watermarks, no limits.`;
}
+ if (routeAction.type === 'generic-mirror') {
+ return `The fastest online video mirrorer, powered by WebCodecs. No upload required, no watermarks, no limits.`;
+ }
+
if (routeAction.type === 'rotate-format') {
return `The fastest online ${renderHumanReadableContainer(
routeAction.format,
)} rotator, powered by WebCodecs. No upload required, no watermarks, no limits.`;
}
+ if (routeAction.type === 'mirror-format') {
+ return `The fastest online ${renderHumanReadableContainer(
+ routeAction.format,
+ )} rotator, powered by WebCodecs. No upload required, no watermarks, no limits.`;
+ }
+
throw new Error(`Invalid route action ${routeAction satisfies never}`);
};
@@ -120,5 +153,13 @@ export const makeSlug = (routeAction: RouteAction) => {
return `/rotate/${routeAction.format}`;
}
+ if (routeAction.type === 'mirror-format') {
+ return `/mirror/${routeAction.format}`;
+ }
+
+ if (routeAction.type === 'generic-mirror') {
+ return `/mirror`;
+ }
+
throw new Error(`Invalid route action ${routeAction satisfies never}`);
};