@remotion/cli
Version:
Control Remotion features using the `npx remotion` command
56 lines (55 loc) • 2.81 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCliOptions = exports.getAndValidateAbsoluteOutputFile = void 0;
const node_fs_1 = __importDefault(require("node:fs"));
const node_path_1 = __importDefault(require("node:path"));
const client_1 = require("@remotion/renderer/client");
const config_1 = require("./config");
const get_env_1 = require("./get-env");
const get_input_props_1 = require("./get-input-props");
const log_1 = require("./log");
const parsed_cli_1 = require("./parsed-cli");
const getAndValidateFrameRange = (logLevel, indent) => {
const frameRange = client_1.BrowserSafeApis.options.framesOption.getValue({
commandLine: parsed_cli_1.parsedCli,
}).value;
if (typeof frameRange === 'number') {
log_1.Log.warn({ logLevel, indent }, 'Selected a single frame. Assuming you want to output an image.');
log_1.Log.warn({ logLevel, indent }, `If you want to render a video, pass a range: '--frames=${frameRange}-${frameRange}'.`);
log_1.Log.warn({ indent, logLevel }, "To dismiss this message, add the '--sequence' flag explicitly.");
}
return frameRange;
};
const getAndValidateAbsoluteOutputFile = (relativeOutputLocation, overwrite, logLevel) => {
const absoluteOutputFile = node_path_1.default.resolve(process.cwd(), relativeOutputLocation);
if (node_fs_1.default.existsSync(absoluteOutputFile) && !overwrite) {
log_1.Log.error({ indent: false, logLevel }, `File at ${absoluteOutputFile} already exists. Use --overwrite to overwrite.`);
process.exit(1);
}
return absoluteOutputFile;
};
exports.getAndValidateAbsoluteOutputFile = getAndValidateAbsoluteOutputFile;
const getCliOptions = (options) => {
var _a;
const frameRange = getAndValidateFrameRange(options.logLevel, false);
const imageSequence = client_1.BrowserSafeApis.options.imageSequenceOption.getValue({
commandLine: parsed_cli_1.parsedCli,
}).value;
const shouldOutputImageSequence = options.isStill
? true
: imageSequence || typeof frameRange === 'number';
return {
frameRange,
shouldOutputImageSequence,
inputProps: (0, get_input_props_1.getInputProps)(null, options.logLevel),
envVariables: (0, get_env_1.getEnvironmentVariables)(null, options.logLevel, options.indent),
stillFrame: (_a = client_1.BrowserSafeApis.options.stillFrameOption.getValue({
commandLine: parsed_cli_1.parsedCli,
}).value) !== null && _a !== void 0 ? _a : 0,
ffmpegOverride: config_1.ConfigInternals.getFfmpegOverrideFunction(),
};
};
exports.getCliOptions = getCliOptions;