Skip to content

Commit 311154d

Browse files
authored
Merge pull request #4353 from akhilender-bongirwar/feat/add-metadata-field
2 parents cf1fc3b + 61bb9f4 commit 311154d

File tree

74 files changed

+496
-58
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+496
-58
lines changed

packages/cli/src/benchmark.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const {
5050
forSeamlessAacConcatenationOption,
5151
publicPathOption,
5252
publicDirOption,
53+
metadataOption,
5354
} = BrowserSafeApis.options;
5455

5556
const getValidConcurrency = (cliConcurrency: number | string | null) => {
@@ -382,6 +383,7 @@ export const benchmarkCommand = async (
382383
},
383384
true,
384385
).value;
386+
const metadata = metadataOption.getValue({commandLine: parsedCli}).value;
385387

386388
for (const composition of compositions) {
387389
const {value: videoCodec, source: codecReason} = videoCodecOption.getValue(
@@ -490,6 +492,7 @@ export const benchmarkCommand = async (
490492
compositionStart: 0,
491493
onBrowserDownload,
492494
onArtifact: () => undefined,
495+
metadata,
493496
},
494497
(run, progress) => {
495498
benchmarkProgress.update(

packages/cli/src/config/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import {
6868
getKeyboardShortcutsEnabled,
6969
setKeyboardShortcutsEnabled,
7070
} from './keyboard-shortcuts';
71+
import {getMetadata, setMetadata} from './metadata';
7172
import {setNumberOfSharedAudioTags} from './number-of-shared-audio-tags';
7273
import {getShouldOpenBrowser, setShouldOpenBrowser} from './open-browser';
7374
import {setOutputLocation} from './output-location';
@@ -502,6 +503,8 @@ type FlatConfig = RemotionConfigObject &
502503
* Set the amount of milliseconds after which the Player in the Studio will display a buffering UI after the Player has entered a buffer state.
503504
*/
504505
setBufferStateDelayInMilliseconds: (delay: number | null) => void;
506+
507+
setMetadata: (metadata: Record<string, string>) => void;
505508
/**
506509
* @deprecated 'The config format has changed. Change `Config.Bundling.*()` calls to `Config.*()` in your config file.'
507510
*/
@@ -598,6 +601,7 @@ export const Config: FlatConfig = {
598601
setJpegQuality: jpegQualityOption.setConfig,
599602
setStillImageFormat,
600603
setVideoImageFormat,
604+
setMetadata,
601605
setEncodingMaxRate: encodingMaxRateOption.setConfig,
602606
setEncodingBufferSize: encodingBufferSizeOption.setConfig,
603607
setFrameRange,
@@ -664,6 +668,7 @@ export const ConfigInternals = {
664668
getFfmpegOverrideFunction,
665669
getHeight,
666670
getWidth,
671+
getMetadata,
667672
getEntryPoint,
668673
getWebpackPolling,
669674
getShouldOpenBrowser,

packages/cli/src/config/metadata.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
let specifiedMetadata: Record<string, string>;
2+
3+
export const setMetadata = (metadata: Record<string, string>): void => {
4+
specifiedMetadata = metadata;
5+
};
6+
7+
export const getMetadata = (): Record<string, string> => {
8+
return specifiedMetadata;
9+
};

packages/cli/src/get-render-defaults.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export const getRenderDefaults = (): RenderDefaults => {
106106
const disableWebSecurity = ConfigInternals.getChromiumDisableWebSecurity();
107107
const ignoreCertificateErrors = ConfigInternals.getIgnoreCertificateErrors();
108108
const userAgent = ConfigInternals.getChromiumUserAgent();
109+
const metadata = ConfigInternals.getMetadata();
109110

110111
const maxConcurrency = RenderInternals.getMaxConcurrency();
111112
const minConcurrency = RenderInternals.getMinConcurrency();
@@ -146,5 +147,6 @@ export const getRenderDefaults = (): RenderDefaults => {
146147
numberOfGifLoops,
147148
beepOnFinish,
148149
forSeamlessAacConcatenation,
150+
metadata,
149151
};
150152
};

packages/cli/src/render-flows/render.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export const renderVideoFlow = async ({
109109
forSeamlessAacConcatenation,
110110
separateAudioTo,
111111
publicPath,
112+
metadata,
112113
}: {
113114
remotionRoot: string;
114115
fullEntryPoint: string;
@@ -162,6 +163,7 @@ export const renderVideoFlow = async ({
162163
forSeamlessAacConcatenation: boolean;
163164
separateAudioTo: string | null;
164165
publicPath: string | null;
166+
metadata: Record<string, string> | null;
165167
}) => {
166168
const isVerbose = RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose');
167169

@@ -597,6 +599,7 @@ export const renderVideoFlow = async ({
597599
compositionStart: 0,
598600
onBrowserDownload,
599601
onArtifact,
602+
metadata: metadata ?? null,
600603
});
601604
if (!updatesDontOverwrite) {
602605
updateRenderProgress({newline: true, printToConsole: true});

packages/cli/src/render-queue/process-video.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,6 @@ export const processVideoJob = async ({
9595
job.type === 'video' ? job.forSeamlessAacConcatenation : false,
9696
separateAudioTo: job.type === 'video' ? job.separateAudioTo : null,
9797
publicPath: null,
98+
metadata: job.metadata,
9899
});
99100
};

packages/cli/src/render.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const {
3737
audioCodecOption,
3838
publicPathOption,
3939
publicDirOption,
40+
metadataOption,
4041
} = BrowserSafeApis.options;
4142

4243
export const render = async (
@@ -162,6 +163,7 @@ export const render = async (
162163
const separateAudioTo = separateAudioOption.getValue({
163164
commandLine: parsedCli,
164165
}).value;
166+
const metadata = metadataOption.getValue({commandLine: parsedCli}).value;
165167
const publicPath = publicPathOption.getValue({commandLine: parsedCli}).value;
166168

167169
const chromiumOptions: ChromiumOptions = {
@@ -236,5 +238,6 @@ export const render = async (
236238
forSeamlessAacConcatenation,
237239
separateAudioTo,
238240
publicPath,
241+
metadata,
239242
});
240243
};

packages/cloudrun/src/api/render-media-on-cloudrun.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type InternalRenderMediaOnCloudrun = {
5858
indent: boolean;
5959
logLevel: LogLevel;
6060
downloadBehavior: DownloadBehavior;
61+
metadata?: Record<string, string> | null;
6162
} & Partial<ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnCloudRun>>;
6263

6364
export type RenderMediaOnCloudrunInput = {
@@ -87,6 +88,7 @@ export type RenderMediaOnCloudrunInput = {
8788
concurrency?: number | string | null;
8889
preferLossless?: boolean;
8990
downloadBehavior?: DownloadBehavior;
91+
metadata?: Record<string, string> | null;
9092
} & Partial<ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnCloudRun>>;
9193

9294
const internalRenderMediaOnCloudrunRaw = async ({
@@ -129,6 +131,7 @@ const internalRenderMediaOnCloudrunRaw = async ({
129131
offthreadVideoCacheSizeInBytes,
130132
colorSpace,
131133
downloadBehavior,
134+
metadata,
132135
}: InternalRenderMediaOnCloudrun): Promise<
133136
RenderMediaOnCloudrunOutput | CloudRunCrashResponse
134137
> => {
@@ -188,6 +191,7 @@ const internalRenderMediaOnCloudrunRaw = async ({
188191
colorSpace: colorSpace ?? null,
189192
clientVersion: VERSION,
190193
downloadBehavior,
194+
metadata: metadata ?? null,
191195
};
192196

193197
const client = await getAuthClientForUrl(cloudRunEndpoint);
@@ -315,6 +319,7 @@ export const internalRenderMediaOnCloudrun = wrapWithErrorHandling(
315319
* @param params.concurrency A number or a string describing how many browser tabs should be opened. Default "50%".
316320
* @param params.enforceAudioTrack Render a silent audio track if there wouldn't be any otherwise.
317321
* @param params.preferLossless Uses a lossless audio codec, if one is available for the codec. If you set audioCodec, it takes priority over preferLossless.
322+
* @param params.metadata Metadata to be attached to the output file.
318323
* @returns {Promise<RenderMediaOnCloudrunOutput>} See documentation for detailed structure
319324
*/
320325
export const renderMediaOnCloudrun = ({
@@ -357,6 +362,7 @@ export const renderMediaOnCloudrun = ({
357362
offthreadVideoCacheSizeInBytes,
358363
colorSpace,
359364
downloadBehavior,
365+
metadata,
360366
}: RenderMediaOnCloudrunInput): Promise<
361367
RenderMediaOnCloudrunOutput | CloudRunCrashResponse
362368
> => {
@@ -404,5 +410,6 @@ export const renderMediaOnCloudrun = ({
404410
downloadBehavior: downloadBehavior ?? {
405411
type: 'play-in-browser',
406412
},
413+
metadata: metadata ?? null,
407414
});
408415
};

packages/cloudrun/src/api/render-still-on-cloudrun.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export type RenderStillOnCloudrunInput = Partial<OptionalParameters> &
6969
* @param params.forceHeight Overrides default composition height.
7070
* @param params.logLevel Level of logging that Cloud Run service should perform. Default "info".
7171
* @param params.delayRenderTimeoutInMilliseconds A number describing how long the render may take to resolve all delayRender() calls before it times out.
72+
* @param params.metadata Metadata to be attached to the output file.
7273
* @returns {Promise<RenderStillOnCloudrunOutput>} See documentation for detailed structure
7374
*/
7475

packages/cloudrun/src/cli/commands/render/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const {
3434
encodingBufferSizeOption,
3535
delayRenderTimeoutInMillisecondsOption,
3636
binariesDirectoryOption,
37+
metadataOption,
3738
} = BrowserSafeApis.options;
3839

3940
export const renderCommand = async (
@@ -276,6 +277,9 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
276277
const encodingBufferSize = encodingBufferSizeOption.getValue({
277278
commandLine: CliInternals.parsedCli,
278279
}).value;
280+
const metadata = metadataOption.getValue({
281+
commandLine: CliInternals.parsedCli,
282+
}).value;
279283

280284
const res = await internalRenderMediaOnCloudrun({
281285
cloudRunUrl,
@@ -320,6 +324,7 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
320324
colorSpace,
321325
indent: false,
322326
downloadBehavior: {type: 'play-in-browser'},
327+
metadata,
323328
});
324329

325330
if (res.type === 'crash') {

0 commit comments

Comments
 (0)