Skip to content

🎥 Make videos programmatically with React

don't show re-encoding if also rotating

Jonny Burgerb8e733066692
diff --git a/packages/convert/app/components/ConvertUi.tsx b/packages/convert/app/components/ConvertUi.tsx
index 75c9e9343a..52bd371765 100644
--- a/packages/convert/app/components/ConvertUi.tsx
+++ b/packages/convert/app/components/ConvertUi.tsx
@@ -101,6 +101,7 @@ export default function ConvertUI({
tracks,
logLevel,
action,
+ userRotation,
});
const setVideoConfigIndex = useCallback((trackId: number, i: number) => {
diff --git a/packages/convert/app/components/get-supported-configs.tsx b/packages/convert/app/components/get-supported-configs.tsx
index 602abde4b9..1ec561b898 100644
--- a/packages/convert/app/components/get-supported-configs.tsx
+++ b/packages/convert/app/components/get-supported-configs.tsx
@@ -56,12 +56,14 @@ export const getSupportedConfigs = async ({
bitrate,
logLevel,
action,
+ userRotation,
}: {
tracks: TracksField;
container: ConvertMediaContainer;
bitrate: number;
logLevel: LogLevel;
action: RouteAction;
+ userRotation: number;
}): Promise<SupportedConfigs> => {
const availableVideoCodecs = getAvailableVideoCodecs({container});
@@ -75,6 +77,8 @@ export const getSupportedConfigs = async ({
const canCopy = canCopyVideoTrack({
inputCodec: track.codecWithoutConfig,
container,
+ inputRotation: track.rotation,
+ rotationToApply: userRotation,
});
if (canCopy && prioritizeCopyOverReencode) {
options.push({
diff --git a/packages/convert/app/components/use-probe.ts b/packages/convert/app/components/use-probe.ts
index e2896efabe..8cebacff62 100644
--- a/packages/convert/app/components/use-probe.ts
+++ b/packages/convert/app/components/use-probe.ts
@@ -23,7 +23,7 @@ export const useProbe = ({
}: {
src: Source;
logLevel: LogLevel;
- onVideoThumbnail: (videoFrame: VideoFrame, rotation: number) => void;
+ onVideoThumbnail: (videoFrame: VideoFrame) => void;
onProgress: ParseMediaOnProgress;
}) => {
const [audioCodec, setAudioCodec] = useState<
@@ -112,7 +112,7 @@ export const useProbe = ({
console.log(error);
},
output(frame) {
- onVideoThumbnail(frame, track.rotation);
+ onVideoThumbnail(frame);
frame.close();
hasFrame = true;
cancelIfDone();
diff --git a/packages/convert/app/components/use-supported-configs.ts b/packages/convert/app/components/use-supported-configs.ts
index 4907f9c816..539dd626d9 100644
--- a/packages/convert/app/components/use-supported-configs.ts
+++ b/packages/convert/app/components/use-supported-configs.ts
@@ -9,11 +9,13 @@ export const useSupportedConfigs = ({
tracks,
logLevel,
action,
+ userRotation,
}: {
container: ConvertMediaContainer;
tracks: TracksField | null;
logLevel: LogLevel;
action: RouteAction;
+ userRotation: number;
}) => {
const [state, setState] = useState<
Record<ConvertMediaContainer, SupportedConfigs | null>
@@ -30,13 +32,14 @@ export const useSupportedConfigs = ({
bitrate: 128000,
logLevel,
action,
+ userRotation,
}).then((supportedConfigs) => {
setState((prev) => ({
...prev,
[container]: supportedConfigs,
}));
});
- }, [action, container, logLevel, tracks]);
+ }, [action, container, logLevel, tracks, userRotation]);
return state[container];
};