Skip to content

🎥 Make videos programmatically with React

added getFrameRange in Internals

Shankhadeep Dey11188e6babc9
diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.ts
index 5174dbefc8..566eb50e70 100644
--- a/packages/cli/src/parse-command-line.ts
+++ b/packages/cli/src/parse-command-line.ts
@@ -20,7 +20,7 @@ export type CommandLineOptions = {
png: boolean;
props: string;
quality: number;
- range: string;
+ range: string | number;
sequence: boolean;
};
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index ffbf371420..60d7195a08 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -34,6 +34,7 @@ export const render = async () => {
const parallelism = Internals.getConcurrency();
const shouldOutputImageSequence = Internals.getShouldOutputImageSequence();
const userCodec = Internals.getOutputCodecOrUndefined();
+ const range = Internals.getFrameRange();
if (shouldOutputImageSequence && userCodec) {
console.error(
'Detected both --codec and --sequence (formerly --png) flag.'
diff --git a/packages/core/src/config/range.ts b/packages/core/src/config/range.ts
index e49af0114e..502643d586 100644
--- a/packages/core/src/config/range.ts
+++ b/packages/core/src/config/range.ts
@@ -15,6 +15,11 @@ export const setFrameRange = (newFrameRange: string | number) => {
`--range flag must be a number or 2 numbers separate by '-', instead got ${frameRange.length} numbers`
);
}
+ if (frameRange.length === 2 && frameRange[1] < frameRange[0]) {
+ throw new Error(
+ 'in --range flag second number should be greater than first number'
+ );
+ }
for (const key in frameRange) {
if (typeof frameRange[key] !== 'number') {
throw new Error(
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index 9c8c3d4d21..6c27047653 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -37,6 +37,7 @@ import {
validateSelectedPixelFormatAndCodecCombination,
} from './config/pixel-format';
import {getQuality} from './config/quality';
+import {getFrameRange} from './config/range';
import * as perf from './perf';
import {getCompositionName, getIsEvaluation, getRoot} from './register-root';
import {RemotionRoot} from './RemotionRoot';
@@ -59,6 +60,7 @@ export const Internals = {
getIsEvaluation,
getPixelFormat,
getConcurrency,
+ getFrameRange,
getShouldOverwrite,
getOutputCodecOrUndefined,
getWebpackOverrideFn,
diff --git a/packages/renderer/src/render.ts b/packages/renderer/src/render.ts
index ffa6f1e141..1567650d8a 100644
--- a/packages/renderer/src/render.ts
+++ b/packages/renderer/src/render.ts
@@ -1,5 +1,5 @@
import path from 'path';
-import {Browser, Internals, VideoConfig} from 'remotion';
+import {Browser, FrameRange, Internals, VideoConfig} from 'remotion';
import {openBrowser, provideScreenshot} from '.';
import {getActualConcurrency} from './get-concurrency';
import {DEFAULT_IMAGE_FORMAT, ImageFormat} from './image-format';
@@ -30,6 +30,7 @@ export const renderFrames = async ({
imageFormat?: ImageFormat;
quality?: number;
browser?: Browser;
+ frameRange?: FrameRange;
}) => {
if (quality !== undefined && imageFormat !== 'jpeg') {
throw new Error(