Skip to content

🎥 Make videos programmatically with React

hide unavailable options

Jonny Burger035bf601ca6b
diff --git a/packages/convert/app/components/ConvertForm.tsx b/packages/convert/app/components/ConvertForm.tsx
index dff2a7f0ee..8b5d22c857 100644
--- a/packages/convert/app/components/ConvertForm.tsx
+++ b/packages/convert/app/components/ConvertForm.tsx
@@ -7,6 +7,7 @@ import {
getAvailableContainers,
} from '@remotion/webcodecs';
import React from 'react';
+import {isReencoding} from '~/lib/is-reencoding';
import {renderHumanReadableContainer} from '~/lib/render-codec-label';
import {AudioCodecSelection} from './AudioCodecSelection';
import {SupportedConfigs} from './get-supported-configs';
@@ -57,6 +58,9 @@ export const ConvertForm: React.FC<{
}) => {
const [showAdvanced, setShowAdvanced] = React.useState(false);
+ const canPixelManipulate =
+ supportedConfigs && isReencoding({supportedConfigs, videoConfigIndex});
+
return (
<div className="gap-4 grid">
<div>
@@ -125,7 +129,7 @@ export const ConvertForm: React.FC<{
) : (
<SelectionSkeleton />
)}
- {showAdvanced ? (
+ {canPixelManipulate && showAdvanced ? (
<>
<div className="flex flex-row">
<Checkbox
@@ -160,7 +164,7 @@ export const ConvertForm: React.FC<{
</div>
</div>
</>
- ) : (
+ ) : canPixelManipulate ? (
<div className="flex flex-row justify-center text-muted-foreground">
<button
type="button"
@@ -170,7 +174,7 @@ export const ConvertForm: React.FC<{
Advanced settings
</button>
</div>
- )}
+ ) : null}
</div>
);
};
diff --git a/packages/convert/app/components/ConvertUi.tsx b/packages/convert/app/components/ConvertUi.tsx
index fc7ce7f368..c9cbfa2d35 100644
--- a/packages/convert/app/components/ConvertUi.tsx
+++ b/packages/convert/app/components/ConvertUi.tsx
@@ -11,6 +11,7 @@ import {webFileReader} from '@remotion/media-parser/web-file';
import {convertMedia, ConvertMediaContainer} from '@remotion/webcodecs';
import {useCallback, useEffect, useRef, useState} from 'react';
import {ConvertState, Source} from '~/lib/convert-state';
+import {isDroppingEverything} from '~/lib/is-reencoding';
import {ConversionDone} from './ConversionDone';
import {ConvertForm} from './ConvertForm';
import {ConvertProgress, convertProgressRef} from './ConvertProgress';
@@ -250,12 +251,12 @@ export default function ConvertUI({
}
const disableConvert =
- supportedConfigs?.audioTrackOptions.every(
- (o) => o.operations[audioConfigIndex[o.trackId] ?? 0].type === 'drop',
- ) &&
- supportedConfigs?.videoTrackOptions.every(
- (o) => o.operations[videoConfigIndex[o.trackId] ?? 0].type === 'drop',
- );
+ !supportedConfigs ||
+ isDroppingEverything({
+ audioConfigIndex,
+ supportedConfigs,
+ videoConfigIndex,
+ });
return (
<>
diff --git a/packages/convert/app/lib/is-reencoding.ts b/packages/convert/app/lib/is-reencoding.ts
new file mode 100644
index 0000000000..39b17ae404
--- /dev/null
+++ b/packages/convert/app/lib/is-reencoding.ts
@@ -0,0 +1,32 @@
+import {SupportedConfigs} from '~/components/get-supported-configs';
+
+export const isReencoding = ({
+ supportedConfigs,
+ videoConfigIndex,
+}: {
+ supportedConfigs: SupportedConfigs;
+ videoConfigIndex: Record<number, number>;
+}) => {
+ return supportedConfigs.videoTrackOptions.every(
+ (o) => o.operations[videoConfigIndex[o.trackId] ?? 0].type === 'reencode',
+ );
+};
+
+export const isDroppingEverything = ({
+ supportedConfigs,
+ audioConfigIndex,
+ videoConfigIndex,
+}: {
+ supportedConfigs: SupportedConfigs;
+ audioConfigIndex: Record<number, number>;
+ videoConfigIndex: Record<number, number>;
+}) => {
+ return (
+ supportedConfigs.audioTrackOptions.every(
+ (o) => o.operations[audioConfigIndex[o.trackId] ?? 0].type === 'drop',
+ ) &&
+ supportedConfigs.videoTrackOptions.every(
+ (o) => o.operations[videoConfigIndex[o.trackId] ?? 0].type === 'drop',
+ )
+ );
+};