🎥 Make videos programmatically with React
Reuse render output fields for video matting
JonnyBurger09e92dbdb545
diff --git a/packages/studio/src/components/RenderModal/RenderModalBasic.tsx b/packages/studio/src/components/RenderModal/RenderModalBasic.tsxindex 4668f9ed56..b10b0c8dd1 100644--- a/packages/studio/src/components/RenderModal/RenderModalBasic.tsx+++ b/packages/studio/src/components/RenderModal/RenderModalBasic.tsx@@ -224,7 +224,10 @@ export const RenderModalBasic: React.FC<{)}{showOutputName ? (<RenderModalOutputName+ ariaLabel={null}+ existingOutputPath={null}existence={existence}+ inputContainerStyle={null}inputStyle={input}outName={outName}onValueChange={onValueChange}diff --git a/packages/studio/src/components/RenderModal/RenderModalOutputName.tsx b/packages/studio/src/components/RenderModal/RenderModalOutputName.tsxindex f07ded42f4..40d51b1545 100644--- a/packages/studio/src/components/RenderModal/RenderModalOutputName.tsx+++ b/packages/studio/src/components/RenderModal/RenderModalOutputName.tsx@@ -41,7 +41,10 @@ const outputNameInputContainer: React.CSSProperties = {};type Props = {+ readonly ariaLabel: string | null;+ readonly existingOutputPath: string | null;readonly existence: boolean;+ readonly inputContainerStyle: React.CSSProperties | null;readonly inputStyle: React.CSSProperties;readonly outName: string;readonly onValueChange: React.ChangeEventHandler<HTMLInputElement>;@@ -50,7 +53,10 @@ type Props = {};export const RenderModalOutputName = ({+ ariaLabel,+ existingOutputPath,existence,+ inputContainerStyle,inputStyle,outName,onValueChange,@@ -58,10 +64,12 @@ export const RenderModalOutputName = ({label: labelText,}: Props) => {const openExistingOutput = useCallback(() => {- openInFileExplorer({directory: outName}).catch((err) => {- showNotification(`Could not open file: ${err.message}`, 2000);- });- }, [outName]);+ openInFileExplorer({directory: existingOutputPath ?? outName}).catch(+ (err) => {+ showNotification(`Could not open file: ${err.message}`, 2000);+ },+ );+ }, [existingOutputPath, outName]);const renderOpenIcon: RenderInlineAction = useCallback((color) => {return <ExpandedFolderIconSolid style={openIconStyle} color={color} />;@@ -78,8 +86,9 @@ export const RenderModalOutputName = ({<div style={label}>{labelText}</div></Column><div style={rightRow}>- <div style={outputNameInputContainer}>+ <div style={{...outputNameInputContainer, ...inputContainerStyle}}><RemotionInput+ aria-label={ariaLabel ?? undefined}status={validationMessage ? 'error' : existence ? 'warning' : 'ok'}style={inputStyle}type="text"diff --git a/packages/studio/src/components/RenderModal/SeparateAudioOption.tsx b/packages/studio/src/components/RenderModal/SeparateAudioOption.tsxindex 689519a8ff..805f2f254f 100644--- a/packages/studio/src/components/RenderModal/SeparateAudioOption.tsx+++ b/packages/studio/src/components/RenderModal/SeparateAudioOption.tsx@@ -39,7 +39,10 @@ export const SeparateAudioOptionInput: React.FC<{return (<RenderModalOutputName+ ariaLabel={null}+ existingOutputPath={null}existence={existence}+ inputContainerStyle={null}inputStyle={input}onValueChange={onValueChange}outName={separateAudioTo}diff --git a/packages/studio/src/components/RenderModal/WebRenderModalBasic.tsx b/packages/studio/src/components/RenderModal/WebRenderModalBasic.tsxindex 398391f262..316efbe119 100644--- a/packages/studio/src/components/RenderModal/WebRenderModalBasic.tsx+++ b/packages/studio/src/components/RenderModal/WebRenderModalBasic.tsx@@ -249,7 +249,10 @@ export const WebRenderModalBasic: React.FC<WebRenderModalBasicProps> = ({</>)}<RenderModalOutputName+ ariaLabel={null}+ existingOutputPath={null}existence={false}+ inputContainerStyle={null}inputStyle={input}outName={outName}onValueChange={onOutNameChange}diff --git a/packages/studio/src/components/VideoMatting/VideoMattingModal.tsx b/packages/studio/src/components/VideoMatting/VideoMattingModal.tsxindex f879e9816f..4888f3c6a2 100644--- a/packages/studio/src/components/VideoMatting/VideoMattingModal.tsx+++ b/packages/studio/src/components/VideoMatting/VideoMattingModal.tsx@@ -13,7 +13,7 @@ import React, {useMemo,useState,} from 'react';-import {BLUE_DISABLED, WHITE} from '../../helpers/colors';+import {BLUE_DISABLED} from '../../helpers/colors';import {Checkmark} from '../../icons/Checkmark';import type {VideoMattingModalState} from '../../state/modals';import {SetSelectedModalContext} from '../../state/modals';@@ -24,7 +24,6 @@ import {ModalHeader} from '../ModalHeader';import type {ComboboxValue} from '../NewComposition/ComboBox';import {Combobox} from '../NewComposition/ComboBox';import {DismissableModal} from '../NewComposition/DismissableModal';-import {RemotionInput} from '../NewComposition/RemInput';import {ValidationMessage} from '../NewComposition/ValidationMessage';import {optionsSidebarTabs} from '../options-sidebar-tabs';import {persistSelectedOptionsSidebarPanel} from '../OptionsPanel';@@ -41,6 +40,7 @@ import {outerModalStyle,} from '../RenderModal/render-modals';import {RenderModalHr} from '../RenderModal/RenderModalHr';+import {RenderModalOutputName} from '../RenderModal/RenderModalOutputName';import {RenderQueueContext} from '../RenderQueue/context';import {useStaticFiles} from '../use-static-files';@@ -57,14 +57,8 @@ const modalStyle: React.CSSProperties = {maxHeight: 'calc(100vh - 40px)',outline: 'none',};-const outputRow: React.CSSProperties = {...optionRow, alignItems: 'flex-start'};-const fieldLabel: React.CSSProperties = {- color: WHITE,- fontFamily: 'sans-serif',- fontSize: 13,- lineHeight: '32px',-};const validationStyle: React.CSSProperties = {padding: '0 16px 8px'};+const outputInputContainerStyle: React.CSSProperties = {maxWidth: 330};type SupportState =| {type: 'checking'}@@ -261,72 +255,36 @@ export const VideoMattingModal: React.FC<VideoMattingModalState> = ({</Button></div><div style={panelStyle} className={VERTICAL_SCROLLBAR_CLASSNAME}>- <div style={outputRow}>- <div style={fieldLabel}>Base output in public/</div>- <div style={rightRow}>- <RemotionInput- aria-label="Base video output file"- status={baseError ? 'error' : baseExists ? 'warning' : 'ok'}- rightAlign- value={baseOutName}- onChange={(event) => setBaseOutName(event.target.value)}- style={{...input, ...controlStyle}}- />- </div>- </div>- {baseError ? (- <div style={validationStyle}>- <ValidationMessage- align="flex-end"- message={baseError}- type="error"- />- </div>- ) : baseExists ? (- <div style={validationStyle}>- <ValidationMessage- align="flex-end"- message="Exists, will be overwritten"- type="warning"- />- </div>- ) : null}- <div style={outputRow}>- <div style={fieldLabel}>Foreground output in public/</div>- <div style={rightRow}>- <RemotionInput- aria-label="Foreground video output file"- status={- foregroundError- ? 'error'- : foregroundExists- ? 'warning'- : 'ok'- }- rightAlign- value={foregroundOutName}- onChange={(event) => setForegroundOutName(event.target.value)}- style={{...input, ...controlStyle}}- />- </div>- </div>- {foregroundError ? (- <div style={validationStyle}>- <ValidationMessage- align="flex-end"- message={foregroundError}- type="error"- />- </div>- ) : foregroundExists ? (- <div style={validationStyle}>- <ValidationMessage- align="flex-end"- message="Exists, will be overwritten"- type="warning"- />- </div>- ) : null}+ <RenderModalOutputName+ ariaLabel="Base video output file"+ existingOutputPath={+ window.remotion_publicFolderExists+ ? `${window.remotion_publicFolderExists}/${baseOutName}`+ : null+ }+ existence={baseExists}+ inputContainerStyle={outputInputContainerStyle}+ inputStyle={{...input, ...controlStyle}}+ label="Base output in public/"+ onValueChange={(event) => setBaseOutName(event.target.value)}+ outName={baseOutName}+ validationMessage={baseError}+ />+ <RenderModalOutputName+ ariaLabel="Foreground video output file"+ existingOutputPath={+ window.remotion_publicFolderExists+ ? `${window.remotion_publicFolderExists}/${foregroundOutName}`+ : null+ }+ existence={foregroundExists}+ inputContainerStyle={outputInputContainerStyle}+ inputStyle={{...input, ...controlStyle}}+ label="Foreground output in public/"+ onValueChange={(event) => setForegroundOutName(event.target.value)}+ outName={foregroundOutName}+ validationMessage={foregroundError}+ /><RenderModalHr /><div style={optionRow}><div style={label}>Model</div>