Skip to content

🎥 Make videos programmatically with React

make sense

Jonny Burger447ff5710d80
diff --git a/packages/convert/app/components/ConvertUi.tsx b/packages/convert/app/components/ConvertUi.tsx
index 23c585a67a..84ab919111 100644
--- a/packages/convert/app/components/ConvertUi.tsx
+++ b/packages/convert/app/components/ConvertUi.tsx
@@ -96,8 +96,8 @@ export default function ConvertUI({
onVideoFrame: ({frame}) => {
const flipped = flipVideoFrame({
frame,
- horizontal: flipHorizontal,
- vertical: flipVertical,
+ horizontal: flipHorizontal && enableRotateOrMirrow === 'mirror',
+ vertical: flipVertical && enableRotateOrMirrow === 'mirror',
});
if (videoFrames % 15 === 0) {
convertProgressRef.current?.draw(flipped);
@@ -192,12 +192,14 @@ export default function ConvertUI({
};
}, [
src,
+ actualRotation,
container,
flipHorizontal,
flipVertical,
supportedConfigs,
audioConfigIndex,
videoConfigIndex,
+ enableRotateOrMirrow,
]);
const cancel = useCallback(() => {
diff --git a/packages/webcodecs/src/rotate-video.ts b/packages/webcodecs/src/rotate-video.ts
index 8210cadea4..50aedd7dee 100644
--- a/packages/webcodecs/src/rotate-video.ts
+++ b/packages/webcodecs/src/rotate-video.ts
@@ -7,16 +7,15 @@ export const rotateVideo = ({
frame: VideoFrame;
rotation: number;
}) => {
- if (rotation % 360 === 0) {
+ const normalized = ((rotation % 360) + 360) % 360;
+ if (normalized % 360 === 0) {
return frame;
}
- if (rotation % 90 !== 0) {
+ if (normalized % 90 !== 0) {
throw new Error('Only 90 degree rotations are supported');
}
- const normalized = ((rotation % 360) + 360) % 360;
-
const {height, width} = calculateNewDimensionsFromDimensions({
height: frame.displayHeight,
width: frame.displayWidth,