Skip to content

🎥 Make videos programmatically with React

initial cc implemantion

Jonny Burger4de6c059a5ea
diff --git a/packages/studio/src/components/RenderModal/WebRenderModal.tsx b/packages/studio/src/components/RenderModal/WebRenderModal.tsx
index 86e16a7c34..81dd04987d 100644
--- a/packages/studio/src/components/RenderModal/WebRenderModal.tsx
+++ b/packages/studio/src/components/RenderModal/WebRenderModal.tsx
@@ -14,6 +14,7 @@ import {AudioIcon} from '../../icons/audio';
import {DataIcon} from '../../icons/data';
import {FileIcon} from '../../icons/file';
import {PicIcon} from '../../icons/frame';
+import {GearIcon} from '../../icons/gear';
import type {WebRenderModalState} from '../../state/modals';
import {Button} from '../Button';
import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';
@@ -43,6 +44,7 @@ import {
import {WebRenderModalAdvanced} from './WebRenderModalAdvanced';
import {WebRenderModalAudio} from './WebRenderModalAudio';
import {WebRenderModalBasic} from './WebRenderModalBasic';
+import {WebRenderModalLicense} from './WebRenderModalLicense';
import {WebRenderModalPicture} from './WebRenderModalPicture';
type WebRenderModalProps = {
@@ -56,7 +58,13 @@ type WebRenderModalProps = {
export type RenderType = 'still' | 'video';
-type TabType = 'general' | 'data' | 'picture' | 'audio' | 'advanced';
+type TabType =
+ | 'general'
+ | 'data'
+ | 'picture'
+ | 'audio'
+ | 'advanced'
+ | 'license';
const invalidCharacters = ['?', '*', '+', ':', '%'];
@@ -188,6 +196,10 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
const [transparent, setTransparent] = useState(false);
const [muted, setMuted] = useState(false);
+ // License state
+ const [freeLicense, setFreeLicense] = useState(false);
+ const [licenseKey, setLicenseKey] = useState('');
+
const finalEndFrame = useMemo(() => {
if (endFrame === null) {
return resolvedComposition.durationInFrames - 1;
@@ -378,6 +390,14 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
}
}, [outName, imageFormat, renderMode, container]);
+ const finalLicenseKey = useMemo(() => {
+ if (freeLicense) {
+ return 'free-license';
+ }
+
+ return licenseKey || undefined;
+ }, [freeLicense, licenseKey]);
+
const onRenderStill = useCallback(async () => {
const {blob} = await renderStillOnWeb({
composition: {
@@ -396,6 +416,7 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
delayRenderTimeoutInMilliseconds: delayRenderTimeout,
mediaCacheSizeInBytes,
logLevel,
+ licenseKey: finalLicenseKey,
});
const url = URL.createObjectURL(blob);
@@ -424,6 +445,7 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
resolvedComposition.defaultProps,
unresolvedComposition.calculateMetadata,
resolvedComposition.id,
+ finalLicenseKey,
]);
const onRenderVideo = useCallback(async () => {
@@ -456,6 +478,7 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
transparent,
muted,
outputTarget: 'web-fs',
+ licenseKey: finalLicenseKey,
});
setRenderProgress(null);
@@ -493,6 +516,7 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
resolvedComposition.defaultProps,
resolvedComposition.id,
unresolvedComposition.calculateMetadata,
+ finalLicenseKey,
]);
const onRender = useCallback(async () => {
@@ -578,6 +602,16 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
</div>
Advanced
</VerticalTab>
+ <VerticalTab
+ style={horizontalTab}
+ selected={tab === 'license'}
+ onClick={() => setTab('license')}
+ >
+ <div style={iconContainer}>
+ <GearIcon style={icon} />
+ </div>
+ License
+ </VerticalTab>
</div>
<div style={optionsPanel} className={VERTICAL_SCROLLBAR_CLASSNAME}>
{tab === 'general' ? (
@@ -628,7 +662,7 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
/>
) : tab === 'audio' ? (
<WebRenderModalAudio muted={muted} setMuted={setMuted} />
- ) : (
+ ) : tab === 'advanced' ? (
<WebRenderModalAdvanced
renderMode={renderMode}
delayRenderTimeout={delayRenderTimeout}
@@ -638,6 +672,13 @@ const WebRenderModal: React.FC<WebRenderModalProps> = ({
hardwareAcceleration={hardwareAcceleration}
setHardwareAcceleration={setHardwareAcceleration}
/>
+ ) : (
+ <WebRenderModalLicense
+ freeLicense={freeLicense}
+ setFreeLicense={setFreeLicense}
+ licenseKey={licenseKey}
+ setLicenseKey={setLicenseKey}
+ />
)}
</div>
</div>
diff --git a/packages/studio/src/components/RenderModal/WebRenderModalLicense.tsx b/packages/studio/src/components/RenderModal/WebRenderModalLicense.tsx
new file mode 100644
index 0000000000..d746bbe6c8
--- /dev/null
+++ b/packages/studio/src/components/RenderModal/WebRenderModalLicense.tsx
@@ -0,0 +1,88 @@
+import type React from 'react';
+import {useCallback} from 'react';
+import {LIGHT_TEXT} from '../../helpers/colors';
+import {Checkbox} from '../Checkbox';
+import {RemotionInput} from '../NewComposition/RemInput';
+import {label, optionRow, rightRow} from './layout';
+
+type WebRenderModalLicenseProps = {
+ readonly freeLicense: boolean;
+ readonly setFreeLicense: React.Dispatch<React.SetStateAction<boolean>>;
+ readonly licenseKey: string;
+ readonly setLicenseKey: React.Dispatch<React.SetStateAction<string>>;
+};
+
+const tabContainer: React.CSSProperties = {
+ flex: 1,
+};
+
+const descriptionStyle: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontSize: 14,
+ fontFamily: 'sans-serif',
+ paddingLeft: 16,
+ paddingRight: 16,
+ paddingTop: 16,
+ paddingBottom: 8,
+ lineHeight: 1.5,
+};
+
+const inputStyle: React.CSSProperties = {
+ minWidth: 250,
+};
+
+export const WebRenderModalLicense: React.FC<WebRenderModalLicenseProps> = ({
+ freeLicense,
+ setFreeLicense,
+ licenseKey,
+ setLicenseKey,
+}) => {
+ const onFreeLicenseChange = useCallback(() => {
+ setFreeLicense((prev) => !prev);
+ }, [setFreeLicense]);
+
+ const onLicenseKeyChange: React.ChangeEventHandler<HTMLInputElement> =
+ useCallback(
+ (e) => {
+ setLicenseKey(e.target.value);
+ },
+ [setLicenseKey],
+ );
+
+ return (
+ <div style={tabContainer}>
+ <div style={descriptionStyle}>
+ Remotion can be used for free if you are an individual or company with a
+ headcount of 3 or less people.
+ </div>
+ <div style={optionRow}>
+ <div style={label}>I am eligible for the free license</div>
+ <div style={rightRow}>
+ <Checkbox
+ checked={freeLicense}
+ onChange={onFreeLicenseChange}
+ name="free-license"
+ />
+ </div>
+ </div>
+ <div style={descriptionStyle}>
+ If you are not eligible for the free license, you need to obtain a
+ company license. If you have one, add your public license key below.
+ </div>
+ <div style={optionRow}>
+ <div style={label}>License Key</div>
+ <div style={rightRow}>
+ <RemotionInput
+ value={licenseKey}
+ onChange={onLicenseKeyChange}
+ placeholder="Enter your license key"
+ status="ok"
+ rightAlign={false}
+ style={inputStyle}
+ disabled={freeLicense}
+ />
+ </div>
+ </div>
+ </div>
+ );
+};