Skip to content

🎥 Make videos programmatically with React

--public-path flag

Jonny Burgerd9e54281087c
diff --git a/packages/bundler/src/bundle.ts b/packages/bundler/src/bundle.ts
index 734feeef3b..bd1fcc747e 100644
--- a/packages/bundler/src/bundle.ts
+++ b/packages/bundler/src/bundle.ts
@@ -41,17 +41,19 @@ const trimTrailingSlash = (p: string): string => {
return p;
};
-export type LegacyBundleOptions = {
- webpackOverride?: WebpackOverrideFn;
- outDir?: string;
- enableCaching?: boolean;
- publicPath?: string;
- rootDir?: string;
- publicDir?: string | null;
- onPublicDirCopyProgress?: (bytes: number) => void;
- onSymlinkDetected?: (path: string) => void;
+export type MandatoryLegacyBundleOptions = {
+ webpackOverride: WebpackOverrideFn;
+ outDir: string | null;
+ enableCaching: boolean;
+ publicPath: string | null;
+ rootDir: string | null;
+ publicDir: string | null;
+ onPublicDirCopyProgress: (bytes: number) => void;
+ onSymlinkDetected: (path: string) => void;
};
+export type LegacyBundleOptions = Partial<MandatoryLegacyBundleOptions>;
+
export const getConfig = ({
entryPoint,
outDir,
@@ -87,15 +89,25 @@ export const getConfig = ({
});
};
+type NewBundleOptions = {
+ entryPoint: string;
+ onProgress: (progress: number) => void;
+ ignoreRegisterRootWarning: boolean;
+ onDirectoryCreated: (dir: string) => void;
+ gitSource: GitSource | null;
+ maxTimelineTracks: number | null;
+ bufferStateDelayInMilliseconds: number | null;
+};
+
+type MandatoryBundleOptions = {
+ entryPoint: string;
+} & NewBundleOptions &
+ MandatoryLegacyBundleOptions;
+
export type BundleOptions = {
entryPoint: string;
- onProgress?: (progress: number) => void;
- ignoreRegisterRootWarning?: boolean;
- onDirectoryCreated?: (dir: string) => void;
- gitSource?: GitSource | null;
- maxTimelineTracks?: number;
- bufferStateDelayInMilliseconds?: number;
-} & LegacyBundleOptions;
+} & Partial<NewBundleOptions> &
+ LegacyBundleOptions;
type Arguments =
| [options: BundleOptions]
@@ -164,12 +176,9 @@ const validateEntryPoint = async (entryPoint: string) => {
}
};
-/**
- * @description The method bundles a Remotion project using Webpack and prepares it for rendering using renderMedia()
- * @see [Documentation](https://www.remotion.dev/docs/bundle)
- */
-export async function bundle(...args: Arguments): Promise<string> {
- const actualArgs = convertArgumentsIntoOptions(args);
+export const internalBundle = async (
+ actualArgs: MandatoryBundleOptions,
+): Promise<string> => {
const entryPoint = path.resolve(process.cwd(), actualArgs.entryPoint);
const resolvedRemotionRoot =
actualArgs?.rootDir ??
@@ -301,4 +310,31 @@ export async function bundle(...args: Arguments): Promise<string> {
path.join(outDir, SOURCE_MAP_ENDPOINT.replace('/', '')),
);
return outDir;
+};
+
+/**
+ * @description The method bundles a Remotion project using Webpack and prepares it for rendering.
+ * @see [Documentation](https://www.remotion.dev/docs/bundle)
+ */
+export async function bundle(...args: Arguments): Promise<string> {
+ const actualArgs = convertArgumentsIntoOptions(args);
+ const result = await internalBundle({
+ bufferStateDelayInMilliseconds:
+ actualArgs.bufferStateDelayInMilliseconds ?? null,
+ enableCaching: actualArgs.enableCaching ?? true,
+ entryPoint: actualArgs.entryPoint,
+ gitSource: actualArgs.gitSource ?? null,
+ ignoreRegisterRootWarning: actualArgs.ignoreRegisterRootWarning ?? false,
+ maxTimelineTracks: actualArgs.maxTimelineTracks ?? null,
+ onDirectoryCreated: actualArgs.onDirectoryCreated ?? (() => {}),
+ onProgress: actualArgs.onProgress ?? (() => {}),
+ onPublicDirCopyProgress: actualArgs.onPublicDirCopyProgress ?? (() => {}),
+ onSymlinkDetected: actualArgs.onSymlinkDetected ?? (() => {}),
+ outDir: actualArgs.outDir ?? null,
+ publicDir: actualArgs.publicDir ?? null,
+ publicPath: actualArgs.publicPath ?? null,
+ rootDir: actualArgs.rootDir ?? null,
+ webpackOverride: actualArgs.webpackOverride ?? ((f) => f),
+ });
+ return result;
}
diff --git a/packages/bundler/src/index.ts b/packages/bundler/src/index.ts
index a29f5ef946..5fa53e28be 100644
--- a/packages/bundler/src/index.ts
+++ b/packages/bundler/src/index.ts
@@ -1,4 +1,4 @@
-import {findClosestFolderWithItem, getConfig} from './bundle';
+import {findClosestFolderWithItem, getConfig, internalBundle} from './bundle';
import {indexHtml} from './index-html';
import {readRecursively} from './read-recursively';
import {cacheExists, clearCache} from './webpack-cache';
@@ -15,9 +15,15 @@ export const BundlerInternals = {
getConfig,
readRecursively,
findClosestFolderWithItem,
+ internalBundle,
};
export type {GitSource} from '@remotion/studio';
-export {bundle, BundleOptions, LegacyBundleOptions} from './bundle';
+export {
+ bundle,
+ BundleOptions,
+ LegacyBundleOptions,
+ MandatoryLegacyBundleOptions,
+} from './bundle';
export {WebpackConfiguration, WebpackOverrideFn} from './webpack-config';
export {webpack};
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index 98697c79bd..7fa2ee2534 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -47,6 +47,7 @@ const {
overwriteOption,
binariesDirectoryOption,
forSeamlessAacConcatenationOption,
+ publicPathOption,
} = BrowserSafeApis.options;
const getValidConcurrency = (cliConcurrency: number | string | null) => {
@@ -218,6 +219,7 @@ export const benchmarkCommand = async (
}).value;
const gl = glOption.getValue({commandLine: parsedCli}).value;
const headless = headlessOption.getValue({commandLine: parsedCli}).value;
+ const publicPath = publicPathOption.getValue({commandLine: parsedCli}).value;
const chromiumOptions: ChromiumOptions = {
disableWebSecurity,
@@ -258,6 +260,7 @@ export const benchmarkCommand = async (
gitSource: null,
bufferStateDelayInMilliseconds: null,
maxTimelineTracks: null,
+ publicPath,
});
registerCleanupJob(() => cleanupBundle());
diff --git a/packages/cli/src/bundle.ts b/packages/cli/src/bundle.ts
index e65ac6d82e..392e49c2f2 100644
--- a/packages/cli/src/bundle.ts
+++ b/packages/cli/src/bundle.ts
@@ -1,5 +1,6 @@
import {BundlerInternals} from '@remotion/bundler';
import type {LogLevel} from '@remotion/renderer';
+import {BrowserSafeApis} from '@remotion/renderer/client';
import {StudioServerInternals} from '@remotion/studio-server';
import {existsSync, readdirSync, readFileSync, rmSync, writeFileSync} from 'fs';
import path from 'path';
@@ -13,6 +14,8 @@ import {bundleOnCli} from './setup-cache';
import {shouldUseNonOverlayingLogger} from './should-use-non-overlaying-logger';
import {yesOrNo} from './yes-or-no';
+const {publicPathOption} = BrowserSafeApis.options;
+
export const bundleCommand = async (
remotionRoot: string,
args: string[],
@@ -55,6 +58,8 @@ export const bundleCommand = async (
logLevel,
});
+ const publicPath = publicPathOption.getValue({commandLine: parsedCli}).value;
+
const outputPath = parsedCli['out-dir']
? path.resolve(process.cwd(), parsedCli['out-dir'])
: path.join(remotionRoot, 'build');
@@ -122,6 +127,7 @@ export const bundleCommand = async (
gitSource,
bufferStateDelayInMilliseconds: null,
maxTimelineTracks: null,
+ publicPath,
});
Log.info(
diff --git a/packages/cli/src/compositions.ts b/packages/cli/src/compositions.ts
index e9593ab0a1..6918a5e529 100644
--- a/packages/cli/src/compositions.ts
+++ b/packages/cli/src/compositions.ts
@@ -18,6 +18,7 @@ const {
headlessOption,
delayRenderTimeoutInMillisecondsOption,
binariesDirectoryOption,
+ publicPathOption,
} = BrowserSafeApis.options;
export const listCompositionsCommand = async (
@@ -75,6 +76,20 @@ export const listCompositionsCommand = async (
userAgent,
};
+ const publicPath = publicPathOption.getValue({commandLine: parsedCli}).value;
+ const timeoutInMilliseconds = delayRenderTimeoutInMillisecondsOption.getValue(
+ {
+ commandLine: parsedCli,
+ },
+ ).value;
+ const binariesDirectory = binariesDirectoryOption.getValue({
+ commandLine: parsedCli,
+ }).value;
+ const offthreadVideoCacheSizeInBytes =
+ offthreadVideoCacheSizeInBytesOption.getValue({
+ commandLine: parsedCli,
+ }).value;
+
const {urlOrBundle: bundled, cleanup: cleanupBundle} =
await bundleOnCliOrTakeServeUrl({
remotionRoot,
@@ -95,6 +110,7 @@ export const listCompositionsCommand = async (
gitSource: null,
bufferStateDelayInMilliseconds: null,
maxTimelineTracks: null,
+ publicPath,
});
registerCleanupJob(() => cleanupBundle());
@@ -110,22 +126,15 @@ export const listCompositionsCommand = async (
staticBase: null,
indent: undefined,
}).serializedString,
- timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption.getValue({
- commandLine: parsedCli,
- }).value,
+ timeoutInMilliseconds,
port: getRendererPortFromConfigFileAndCliFlag(),
indent: false,
onBrowserLog: null,
puppeteerInstance: undefined,
logLevel,
server: undefined,
- offthreadVideoCacheSizeInBytes:
- offthreadVideoCacheSizeInBytesOption.getValue({
- commandLine: parsedCli,
- }).value,
- binariesDirectory: binariesDirectoryOption.getValue({
- commandLine: parsedCli,
- }).value,
+ offthreadVideoCacheSizeInBytes,
+ binariesDirectory,
});
printCompositions(compositions, logLevel);
diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts
index 905cc88225..a5ce2764e7 100644
--- a/packages/cli/src/config/index.ts
+++ b/packages/cli/src/config/index.ts
@@ -117,6 +117,7 @@ const {
preferLosslessOption,
forSeamlessAacConcatenationOption,
audioCodecOption,
+ publicPathOption,
} = BrowserSafeApis.options;
declare global {
@@ -472,6 +473,10 @@ declare global {
* Prefer lossless audio encoding. Default: false
*/
readonly setPreferLosslessAudio: (lossless: boolean) => void;
+ /**
+ * Prefer lossless audio encoding. Default: false
+ */
+ readonly setPublicPath: (publicPath: string | null) => void;
}
}
@@ -627,6 +632,7 @@ export const Config: FlatConfig = {
setLambdaInsights: enableLambdaInsights.setConfig,
setBinariesDirectory: binariesDirectoryOption.setConfig,
setPreferLosslessAudio: preferLosslessOption.setConfig,
+ setPublicPath: publicPathOption.setConfig,
};
export const ConfigInternals = {
diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.ts
index 5585053e9e..7257bffab9 100644
--- a/packages/cli/src/parse-command-line.ts
+++ b/packages/cli/src/parse-command-line.ts
@@ -30,6 +30,7 @@ const {
audioBitrateOption,
videoBitrateOption,
audioCodecOption,
+ publicPathOption,
} = BrowserSafeApis.options;
type CommandLineOptions = {
@@ -63,6 +64,7 @@ type CommandLineOptions = {
>;
[encodingMaxRateOption.cliFlag]: TypeOfOption<typeof encodingMaxRateOption>;
[audioCodecOption.cliFlag]: AudioCodec;
+ [publicPathOption.cliFlag]: string;
crf: number;
force: boolean;
output: string;
diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.ts
index df43d0c5c4..60178e63dc 100644
--- a/packages/cli/src/render-flows/render.ts
+++ b/packages/cli/src/render-flows/render.ts
@@ -103,6 +103,7 @@ export const renderVideoFlow = async ({
binariesDirectory,
forSeamlessAacConcatenation,
separateAudioTo,
+ publicPath,
}: {
remotionRoot: string;
fullEntryPoint: string;
@@ -155,6 +156,7 @@ export const renderVideoFlow = async ({
binariesDirectory: string | null;
forSeamlessAacConcatenation: boolean;
separateAudioTo: string | null;
+ publicPath: string | null;
}) => {
const downloads: DownloadProgress[] = [];
@@ -248,6 +250,7 @@ export const renderVideoFlow = async ({
gitSource: null,
bufferStateDelayInMilliseconds: null,
maxTimelineTracks: null,
+ publicPath,
},
);
diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.ts
index fda85cabc6..69037130a1 100644
--- a/packages/cli/src/render-flows/still.ts
+++ b/packages/cli/src/render-flows/still.ts
@@ -70,6 +70,7 @@ export const renderStillFlow = async ({
outputLocationFromUi,
offthreadVideoCacheSizeInBytes,
binariesDirectory,
+ publicPath,
}: {
remotionRoot: string;
fullEntryPoint: string;
@@ -99,6 +100,7 @@ export const renderStillFlow = async ({
outputLocationFromUi: string | null;
offthreadVideoCacheSizeInBytes: number | null;
binariesDirectory: string | null;
+ publicPath: string | null;
}) => {
const aggregate: AggregateRenderProgress = initialAggregateRenderProgress();
const updatesDontOverwrite = shouldUseNonOverlayingLogger({logLevel});
@@ -177,6 +179,7 @@ export const renderStillFlow = async ({
gitSource: null,
bufferStateDelayInMilliseconds: null,
maxTimelineTracks: null,
+ publicPath,
},
);
diff --git a/packages/cli/src/render-queue/process-still.ts b/packages/cli/src/render-queue/process-still.ts
index 67c1bee5a3..3c7ee7df6f 100644
--- a/packages/cli/src/render-queue/process-still.ts
+++ b/packages/cli/src/render-queue/process-still.ts
@@ -58,5 +58,6 @@ export const processStill = async ({
outputLocationFromUi: job.outName,
offthreadVideoCacheSizeInBytes: job.offthreadVideoCacheSizeInBytes,
binariesDirectory: job.binariesDirectory,
+ publicPath: null,
});
};
diff --git a/packages/cli/src/render-queue/process-video.ts b/packages/cli/src/render-queue/process-video.ts
index 574b99c4c0..812d960a94 100644
--- a/packages/cli/src/render-queue/process-video.ts
+++ b/packages/cli/src/render-queue/process-video.ts
@@ -85,5 +85,6 @@ export const processVideoJob = async ({
forSeamlessAacConcatenation:
job.type === 'video' ? job.forSeamlessAacConcatenation : false,
separateAudioTo: job.type === 'video' ? job.separateAudioTo : null,
+ publicPath: null,
});
};
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index 6c45491749..791c422f38 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -35,6 +35,7 @@ const {
forSeamlessAacConcatenationOption,
separateAudioOption,
audioCodecOption,
+ publicPathOption,
} = BrowserSafeApis.options;
export const render = async (
@@ -160,6 +161,7 @@ export const render = async (
const separateAudioTo = separateAudioOption.getValue({
commandLine: parsedCli,
}).value;
+ const publicPath = publicPathOption.getValue({commandLine: parsedCli}).value;
const chromiumOptions: ChromiumOptions = {
disableWebSecurity,
@@ -231,5 +233,6 @@ export const render = async (
binariesDirectory,
forSeamlessAacConcatenation,
separateAudioTo,
+ publicPath,
});
};
diff --git a/packages/cli/src/setup-cache.ts b/packages/cli/src/setup-cache.ts
index 839e59e1cd..993b4c7d53 100644
--- a/packages/cli/src/setup-cache.ts
+++ b/packages/cli/src/setup-cache.ts
@@ -1,5 +1,5 @@
-import type {LegacyBundleOptions} from '@remotion/bundler';
-import {bundle, BundlerInternals} from '@remotion/bundler';
+import type {MandatoryLegacyBundleOptions} from '@remotion/bundler';
+import {BundlerInternals} from '@remotion/bundler';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import type {GitSource} from '@remotion/studio';
@@ -29,6 +29,7 @@ export const bundleOnCliOrTakeServeUrl = async ({
gitSource,
bufferStateDelayInMilliseconds,
maxTimelineTracks,
+ publicPath,
}: {
fullPath: string;
remotionRoot: string;
@@ -48,6 +49,7 @@ export const bundleOnCliOrTakeServeUrl = async ({
gitSource: GitSource | null;
bufferStateDelayInMilliseconds: number | null;
maxTimelineTracks: number | null;
+ publicPath: string | null;
}): Promise<{
urlOrBundle: string;
cleanup: () => void;
@@ -85,6 +87,7 @@ export const bundleOnCliOrTakeServeUrl = async ({
gitSource,
bufferStateDelayInMilliseconds,
maxTimelineTracks,
+ publicPath,
});
return {
@@ -109,6 +112,7 @@ export const bundleOnCli = async ({
gitSource,
maxTimelineTracks,
bufferStateDelayInMilliseconds,
+ publicPath,
}: {
fullPath: string;
remotionRoot: string;
@@ -128,6 +132,7 @@ export const bundleOnCli = async ({
gitSource: GitSource | null;
maxTimelineTracks: number | null;
bufferStateDelayInMilliseconds: number | null;
+ publicPath: string | null;
}) => {
const shouldCache = ConfigInternals.getWebpackCaching();
@@ -186,14 +191,15 @@ export const bundleOnCli = async ({
updateProgress(false);
};
- const options: LegacyBundleOptions = {
+ const options: MandatoryLegacyBundleOptions = {
enableCaching: shouldCache,
webpackOverride: ConfigInternals.getWebpackOverrideFn() ?? ((f) => f),
rootDir: remotionRoot,
publicDir,
onPublicDirCopyProgress,
onSymlinkDetected,
- publicPath: './',
+ outDir: outDir ?? null,
+ publicPath,
};
const [hash] = await BundlerInternals.getConfig({
@@ -236,7 +242,7 @@ export const bundleOnCli = async ({
doneIn: null,
};
- const bundled = await bundle({
+ const bundled = await BundlerInternals.internalBundle({
entryPoint: fullPath,
onProgress: (progress) => {
bundlingState = {
@@ -246,9 +252,11 @@ export const bundleOnCli = async ({
updateProgress(false);
},
onDirectoryCreated,
- outDir: outDir ?? undefined,
gitSource,
...options,
+ ignoreRegisterRootWarning: false,
+ maxTimelineTracks,
+ bufferStateDelayInMilliseconds,
});
bundlingState = {
diff --git a/packages/cli/src/still.ts b/packages/cli/src/still.ts
index 853a633030..a8cb6442aa 100644
--- a/packages/cli/src/still.ts
+++ b/packages/cli/src/still.ts
@@ -20,6 +20,7 @@ const {
headlessOption,
overwriteOption,
binariesDirectoryOption,
+ publicPathOption,
} = BrowserSafeApis.options;
export const still = async (
@@ -102,6 +103,9 @@ export const still = async (
const binariesDirectory = binariesDirectoryOption.getValue({
commandLine: parsedCli,
}).value;
+ const publicPath = publicPathOption.getValue({
+ commandLine: parsedCli,
+ }).value;
const chromiumOptions: ChromiumOptions = {
disableWebSecurity,
@@ -148,5 +152,6 @@ export const still = async (
outputLocationFromUi: null,
offthreadVideoCacheSizeInBytes,
binariesDirectory,
+ publicPath,
});
};
diff --git a/packages/docs/docs/bundle.md b/packages/docs/docs/bundle.md
index 63e005efdb..4269f09ce1 100644
--- a/packages/docs/docs/bundle.md
+++ b/packages/docs/docs/bundle.md
@@ -7,26 +7,24 @@ crumb: "@remotion/bundler"
_Part of the `@remotion/bundler` package._
-Bundles a Remotion project using Webpack and prepares it for rendering using [`renderMedia()`](/docs/renderer/render-media).
+Bundles a Remotion project using Webpack and prepares it for rendering using [`renderMedia()`](/docs/renderer/render-media). [See a full server-side rendering example.](/docs/ssr-node)
You only need to call this function when the source code changes. You can render multiple videos from the same bundle and parametrize them using [input props](/docs/passing-props).
Calling `bundle()` for every video that you render is an anti-pattern.
`bundle()` cannot be called in a serverless function, see: [Calling bundle() in bundled code](/docs/troubleshooting/bundling-bundle).
-```ts title="Function signature"
-const bundle: (options?: {
- entryPoint: string;
- onProgress?: (progress: number) => void;
- webpackOverride?: WebpackOverrideFn;
- outDir?: string;
- enableCaching?: boolean;
- publicPath?: string;
- rootDir?: string;
- publicDir?: string | null;
- onPublicDirCopyProgress?: (bytes: number) => void;
- onSymlinkDetected?: (path: string) => void;
-}) => Promise<string>;
+## Example
+
+```tsx twoslash title="render.mjs"
+import path from "path";
+// @module: ESNext
+// @target: ESNext
+import { bundle } from "@remotion/bundler";
+
+const serveUrl = await bundle({
+ entryPoint: path.join(process.cwd(), "./src/index.ts"),
+});
```
## Arguments
@@ -78,7 +76,7 @@ A `boolean` specifying whether Webpack caching should be enabled. Default `true`
_optional_
-The path of the URL where the bundle is going to be hosted. By default it is `/`, meaning that the bundle is going to be hosted at the root of the domain (e.g. `https://localhost:3000/`). In some cases like rendering on Lambda, the public path might be a subdirectory.
+<Options id="public-path"/>
### `rootDir?`<AvailableFrom v="3.1.6" />
diff --git a/packages/docs/docs/cli/bundle.md b/packages/docs/docs/cli/bundle.md
index 03d752809c..43a941b9ec 100644
--- a/packages/docs/docs/cli/bundle.md
+++ b/packages/docs/docs/cli/bundle.md
@@ -24,7 +24,7 @@ Specify a location for the Remotion config file.
### `--log`
-[Set the log level](/docs/config#setlevel). Increase or decrease the amount of output. Acceptable values: `error`, `warn`, `info` (_default_), `verbose`
+<Options id="log" />
### `--public-dir`
@@ -33,3 +33,7 @@ Specify a location for the Remotion config file.
### `--out-dir`
Define the location of the resulting bundle. By default it is a folder called `./build`, adjacent to the [Remotion Root](/docs/terminology/remotion-root).
+
+### `--public-path`<AvailableFrom v="4.0.127"/>
+
+<Options id="public-path" />
diff --git a/packages/renderer/src/options/index.tsx b/packages/renderer/src/options/index.tsx
index 06aa902cf9..fff46acb31 100644
--- a/packages/renderer/src/options/index.tsx
+++ b/packages/renderer/src/options/index.tsx
@@ -22,6 +22,7 @@ import {offthreadVideoCacheSizeInBytesOption} from './offthreadvideo-cache-size'
import type {AnyRemotionOption} from './option';
import {overwriteOption} from './overwrite';
import {preferLosslessAudioOption} from './prefer-lossless';
+import {publicPathOption} from './public-path';
import {reproOption} from './repro';
import {scaleOption} from './scale';
import {separateAudioOption} from './separate-audio';
@@ -63,6 +64,7 @@ export const allOptions = {
binariesDirectoryOption,
forSeamlessAacConcatenationOption,
separateAudioOption,
+ publicPathOption,
};
export type AvailableOptions = keyof typeof allOptions;
diff --git a/packages/renderer/src/options/public-path.tsx b/packages/renderer/src/options/public-path.tsx
new file mode 100644
index 0000000000..9ff3597b8d
--- /dev/null
+++ b/packages/renderer/src/options/public-path.tsx
@@ -0,0 +1,47 @@
+import type {AnyRemotionOption} from './option';
+
+const cliFlag = 'public-path' as const;
+
+let currentPublicPath: string | null = null;
+
+export const publicPathOption = {
+ name: 'Public Path',
+ cliFlag,
+ description: () => {
+ return (
+ <>
+ The path of the URL where the bundle is going to be hosted. By default
+ it is <code>/</code>, meaning that the bundle is going to be hosted at
+ the root of the domain (e.g. <code>https://localhost:3000/</code>). If
+ you are deploying to a subdirectory (e.g. <code>/sites/my-site/</code>),
+ you should set this to the subdirectory.
+ </>
+ );
+ },
+ ssrName: 'publicPath' as const,
+ docLink: 'https://www.remotion.dev/docs/renderer',
+ getValue: ({commandLine}) => {
+ if (commandLine[cliFlag] !== undefined) {
+ return {
+ source: 'cli',
+ value: commandLine[cliFlag] as string,
+ };
+ }
+
+ if (currentPublicPath !== null) {
+ return {
+ source: 'config',
+ value: currentPublicPath,
+ };
+ }
+
+ return {
+ source: 'default',
+ value: null,
+ };
+ },
+ setConfig: (value: string | null) => {
+ currentPublicPath = value;
+ },
+ type: '' as string | null,
+} satisfies AnyRemotionOption<string | null>;