Skip to content

🎥 Make videos programmatically with React

`@remotion/renderer`: Fix `--image-sequence-pattern` precedence over the config file

Jillur Rahman72e47ab18307
diff --git a/packages/renderer/src/options/image-sequence-pattern.tsx b/packages/renderer/src/options/image-sequence-pattern.tsx
index ef689bc9ec..a3b919d8e9 100644
--- a/packages/renderer/src/options/image-sequence-pattern.tsx
+++ b/packages/renderer/src/options/image-sequence-pattern.tsx
@@ -19,6 +19,13 @@ export const imageSequencePatternOption = {
docLink: null,
type: 'string' as string | null,
getValue: ({commandLine}) => {
+ if (commandLine[cliFlag] !== undefined) {
+ return {
+ value: commandLine[cliFlag] as string,
+ source: 'cli',
+ };
+ }
+
if (currentImageSequencePattern !== null) {
return {
value: currentImageSequencePattern,
@@ -27,8 +34,8 @@ export const imageSequencePatternOption = {
}
return {
- value: commandLine[cliFlag] as string,
- source: 'cli',
+ value: null,
+ source: 'default',
};
},
setConfig: (pattern: string | null) => {
diff --git a/packages/renderer/src/test/image-sequence-pattern-option.test.ts b/packages/renderer/src/test/image-sequence-pattern-option.test.ts
new file mode 100644
index 0000000000..e137d33fd0
--- /dev/null
+++ b/packages/renderer/src/test/image-sequence-pattern-option.test.ts
@@ -0,0 +1,30 @@
+import {afterEach, expect, test} from 'bun:test';
+import {imageSequencePatternOption} from '../options/image-sequence-pattern';
+
+afterEach(() => {
+ imageSequencePatternOption.setConfig(null);
+});
+
+test('--image-sequence-pattern takes precedence over the config file', () => {
+ imageSequencePatternOption.setConfig('config-[frame].[ext]');
+ expect(
+ imageSequencePatternOption.getValue({
+ commandLine: {'image-sequence-pattern': 'cli-[frame].[ext]'},
+ }),
+ ).toEqual({source: 'cli', value: 'cli-[frame].[ext]'});
+});
+
+test('the config file applies when the flag is not passed', () => {
+ imageSequencePatternOption.setConfig('config-[frame].[ext]');
+ expect(imageSequencePatternOption.getValue({commandLine: {}})).toEqual({
+ source: 'config',
+ value: 'config-[frame].[ext]',
+ });
+});
+
+test('without the flag or the config, there is no pattern', () => {
+ expect(imageSequencePatternOption.getValue({commandLine: {}})).toEqual({
+ source: 'default',
+ value: null,
+ });
+});