@remotion/renderer
Version:
Render Remotion videos using Node.js or Bun
98 lines (97 loc) • 3.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.videoImageFormatOption = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const image_format_1 = require("../image-format");
const is_audio_codec_1 = require("../is-audio-codec");
let currentVideoImageFormat = null;
const cliFlag = 'image-format';
exports.videoImageFormatOption = {
name: 'Video Image Format',
cliFlag,
description: () => (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: ["The image format to use when rendering frames for a video. Must be one of", ' ', image_format_1.validVideoImageFormats.map((f) => `"${f}"`).join(', '), ". Default:", ' ', jsx_runtime_1.jsx("code", { children: "\"jpeg\"" }),
". JPEG is faster, but does not support transparency."] })),
ssrName: 'imageFormat',
docLink: 'https://www.remotion.dev/docs/renderer/render-media#imageformat',
type: null,
getValue: ({ commandLine }, options) => {
if (options === null || options === void 0 ? void 0 : options.uiVideoImageFormat) {
return {
source: 'via UI',
value: options.uiVideoImageFormat,
};
}
if (commandLine[cliFlag] !== undefined) {
const value = commandLine[cliFlag];
if (!image_format_1.validVideoImageFormats.includes(value)) {
throw new Error(`Invalid video image format: ${value}. Must be one of: ${image_format_1.validVideoImageFormats.join(', ')}`);
}
return {
source: 'from --image-format flag',
value,
};
}
if (options && options.compositionDefaultVideoImageFormat !== null) {
return {
source: 'via calculateMetadata',
value: options.compositionDefaultVideoImageFormat,
};
}
if (currentVideoImageFormat !== null) {
return {
source: 'Config file',
value: currentVideoImageFormat,
};
}
if (options) {
if ((0, is_audio_codec_1.isAudioCodec)(options.codec)) {
return {
source: 'default',
value: 'none',
};
}
if (options.codec === 'h264' ||
options.codec === 'h264-mkv' ||
options.codec === 'h264-ts' ||
options.codec === 'h265' ||
options.codec === 'av1' ||
options.codec === 'vp8' ||
options.codec === 'vp9' ||
options.codec === 'prores' ||
options.codec === 'gif') {
return {
source: 'default',
value: 'jpeg',
};
}
if (options.codec === undefined) {
return {
source: 'default',
value: 'png',
};
}
throw new Error('Unrecognized codec ' + options.codec);
}
return {
source: 'default',
value: null,
};
},
setConfig: (value) => {
if (value === null) {
currentVideoImageFormat = null;
return;
}
if (!image_format_1.validVideoImageFormats.includes(value)) {
throw new TypeError([
`Value ${value} is not valid as a video image format.`,
// @ts-expect-error
value === 'jpg' ? 'Did you mean "jpeg"?' : null,
]
.filter(Boolean)
.join(' '));
}
currentVideoImageFormat = value;
},
id: 'video-image-format',
};