π₯ Make videos programmatically with React
generic convert action
Jonny Burgerba7ac2f5b049
diff --git a/packages/convert/app/routes/convert._index.tsx b/packages/convert/app/routes/convert._index.tsxindex 429d9f06e4..f9728c86e6 100644--- a/packages/convert/app/routes/convert._index.tsx+++ b/packages/convert/app/routes/convert._index.tsx@@ -3,7 +3,10 @@ import {getHeaderTitle, getPageTitle} from '~/seo';const Index = () => {return (- <Main headerTitle={getHeaderTitle(null)} pageTitle={getPageTitle(null)} />+ <Main+ headerTitle={getHeaderTitle({type: 'generic-convert'})}+ pageTitle={getPageTitle({type: 'generic-convert'})}+ />);};diff --git a/packages/convert/app/seo.ts b/packages/convert/app/seo.tsindex 11829b31b4..b353daebf4 100644--- a/packages/convert/app/seo.ts+++ b/packages/convert/app/seo.ts@@ -1,10 +1,11 @@+import {ParseMediaContainer} from '@remotion/media-parser';import {ConvertMediaContainer,getAvailableContainers,} from '@remotion/webcodecs';import {renderHumanReadableContainer} from './lib/render-codec-label';-export const inputContainers: string[] = ['mp4', 'webm', 'avi'];+export const inputContainers: ParseMediaContainer[] = ['mp4', 'webm', 'avi'];export const outputContainers = getAvailableContainers();export const parseRouteAction = (action: string) => {@@ -23,32 +24,48 @@ export const parseRouteAction = (action: string) => {};};-export type RouteAction = {- type: 'convert';- input: ConvertMediaContainer;- output: ConvertMediaContainer;-};+export type RouteAction =+ | {+ type: 'convert';+ input: ConvertMediaContainer | ParseMediaContainer;+ output: ConvertMediaContainer;+ }+ | {+ type: 'generic-convert';+ };-export const getHeaderTitle = (routeAction: RouteAction | null) => {- if (routeAction && routeAction.type === 'convert') {+export const getHeaderTitle = (routeAction: RouteAction) => {+ if (routeAction.type === 'convert') {return `Fast ${renderHumanReadableContainer(routeAction.input)} β ${renderHumanReadableContainer(routeAction.output)} conversion in the browser`;}- return 'Fast video conversion in the browser';+ if (routeAction.type === 'generic-convert') {+ return 'Fast video conversion in the browser';+ }++ throw new Error('Invalid route action');};-export const getPageTitle = (routeAction: RouteAction | null) => {- if (routeAction === null) {+export const getPageTitle = (routeAction: RouteAction) => {+ if (routeAction.type === 'generic-convert') {return 'Remotion Convert β Fast video conversion in the browser';}- return `Online ${renderHumanReadableContainer(routeAction.input)} to ${renderHumanReadableContainer(routeAction.output)} converter - Remotion Convert`;+ if (routeAction.type === 'convert') {+ return `Online ${renderHumanReadableContainer(routeAction.input)} to ${renderHumanReadableContainer(routeAction.output)} converter - Remotion Convert`;+ }++ throw new Error('Invalid route action');};-export const getDescription = (routeAction: RouteAction | null) => {- if (routeAction === null) {+export const getDescription = (routeAction: RouteAction) => {+ if (routeAction.type === 'generic-convert') {return 'The fastest online video converter, powered by WebCodecs. No upload required, no watermarks, no limits.';}- return `The fastest online ${renderHumanReadableContainer(routeAction.input)} to ${renderHumanReadableContainer(routeAction.output)} converter, powered by WebCodecs. No upload required, no watermarks, no limits.`;+ if (routeAction.type === 'convert') {+ return `The fastest online ${renderHumanReadableContainer(routeAction.input)} to ${renderHumanReadableContainer(routeAction.output)} converter, powered by WebCodecs. No upload required, no watermarks, no limits.`;+ }++ throw new Error('Invalid route action');};diff --git a/packages/docs/copy-convert.ts b/packages/docs/copy-convert.tsindex 50d56d395b..154736701a 100644--- a/packages/docs/copy-convert.ts+++ b/packages/docs/copy-convert.ts@@ -4,6 +4,7 @@ import path from 'path';// @ts-ignore outside projectimport * as seo from '../convert/app/seo';+// @ts-expect-errorawait $`bunx turbo "@remotion/convert#build-spa"`;const dir = path.join(__dirname, '../convert/spa-dist/client');@@ -61,7 +62,10 @@ const getContentWithTitle = (title: string, description: string) => {writeFileSync(path.join(__dirname, './build/convert/index.html'),- getContentWithTitle(seo.getPageTitle(null), seo.getDescription(null)),+ getContentWithTitle(+ seo.getPageTitle({type: 'generic-convert'}),+ seo.getDescription({type: 'generic-convert'}),+ ),);for (const page of extraPages) {