🎥 Make videos programmatically with React
rotation
Jonny Burger492f638e6afb
diff --git a/packages/convert/app/components/ConvertUi.tsx b/packages/convert/app/components/ConvertUi.tsxindex 26b52aa96d..aad3ace390 100644--- a/packages/convert/app/components/ConvertUi.tsx+++ b/packages/convert/app/components/ConvertUi.tsx@@ -80,7 +80,7 @@ export default function ConvertUI({const [rotation, setRotation] = useState(90);const actualRotation = useMemo(() => {- if (enableRotateOrMirrow !== 'mirror') {+ if (enableRotateOrMirrow !== 'rotate') {// TODO: Native rotationreturn 0;}diff --git a/packages/convert/app/lib/default-ui.ts b/packages/convert/app/lib/default-ui.tsindex 5dd7e466f2..ca79214461 100644--- a/packages/convert/app/lib/default-ui.ts+++ b/packages/convert/app/lib/default-ui.ts@@ -17,6 +17,10 @@ export const defaultRotateOrMirorState = (return 'rotate';}+ if (action.type === 'rotate-format') {+ return 'rotate';+ }+throw new Error('Rotate is not enabled by default ' + (action satisfies never),);@@ -35,6 +39,10 @@ export const isConvertEnabledByDefault = (action: RouteAction) => {return false;}+ if (action.type === 'rotate-format') {+ return false;+ }+throw new Error('Convert is not enabled by default ' + (action satisfies never),);@@ -45,7 +53,7 @@ export type ConvertSections = 'convert' | 'rotate' | 'mirror';export const getOrderOfSections = (action: RouteAction,): {[key in ConvertSections]: number} => {- if (action.type === 'generic-rotate') {+ if (action.type === 'generic-rotate' || action.type === 'rotate-format') {return {rotate: 0,mirror: 1,diff --git a/packages/convert/app/routes/convert.$action.tsx b/packages/convert/app/routes/convert.$action.tsxindex 4266b1400f..f059ec0bbc 100644--- a/packages/convert/app/routes/convert.$action.tsx+++ b/packages/convert/app/routes/convert.$action.tsx@@ -1,13 +1,13 @@import {useParams} from '@remix-run/react';import {useMemo} from 'react';import {Main} from '~/components/Main';-import {parseRouteAction, RouteAction} from '~/seo';+import {parseConvertRouteAction, RouteAction} from '~/seo';const Index = () => {const action = useParams().action as string;const routeAction: RouteAction = useMemo(() => {- const {input, output} = parseRouteAction(action);+ const {input, output} = parseConvertRouteAction(action);return {type: 'convert',diff --git a/packages/convert/app/routes/rotate.$format.tsx b/packages/convert/app/routes/rotate.$format.tsxnew file mode 100644index 0000000000..1e91ff4ce5--- /dev/null+++ b/packages/convert/app/routes/rotate.$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: 'rotate-format',+ format,+ };+ }, [format]);++ return <Main routeAction={routeAction} />;+};++export default Index;diff --git a/packages/convert/app/seo.ts b/packages/convert/app/seo.tsindex b8cc2fbb93..d0a57cba24 100644--- a/packages/convert/app/seo.ts+++ b/packages/convert/app/seo.ts@@ -8,7 +8,7 @@ import {renderHumanReadableContainer} from './lib/render-codec-label';export const inputContainers: ParseMediaContainer[] = ['mp4', 'webm', 'avi'];export const outputContainers = getAvailableContainers();-export const parseRouteAction = (action: string) => {+export const parseConvertRouteAction = (action: string) => {const split = action.split('-to-');if (split.length !== 2) {throw new Error('Invalid action');@@ -35,6 +35,10 @@ export type RouteAction =}| {type: 'generic-rotate';+ }+ | {+ type: 'rotate-format';+ format: ConvertMediaContainer;};export const getHeaderTitle = (routeAction: RouteAction) => {@@ -50,6 +54,10 @@ export const getHeaderTitle = (routeAction: RouteAction) => {return 'Fast video rotation in the browser';}+ if (routeAction.type === 'rotate-format') {+ return `Fast ${renderHumanReadableContainer(routeAction.format)} rotation in the browser`;+ }+throw new Error(`Invalid route action ${routeAction satisfies never}`);};@@ -66,6 +74,10 @@ export const getPageTitle = (routeAction: RouteAction) => {return 'Online video Rotation - Remotion Convert';}+ if (routeAction.type === 'rotate-format') {+ return `Online ${renderHumanReadableContainer(routeAction.format)} Rotator - Remotion Convert`;+ }+throw new Error(`Invalid route action ${routeAction satisfies never}`);};@@ -82,6 +94,12 @@ export const getDescription = (routeAction: RouteAction) => {return `The fastest online video rotator, 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.`;+ }+throw new Error(`Invalid route action ${routeAction satisfies never}`);};@@ -98,5 +116,9 @@ export const makeSlug = (routeAction: RouteAction) => {return '/rotate';}+ if (routeAction.type === 'rotate-format') {+ return `/rotate/${routeAction.format}`;+ }+throw new Error(`Invalid route action ${routeAction satisfies never}`);};