🎥 Make videos programmatically with React
split up still image format
Jonny Burgera056c302e56d
diff --git a/packages/bundler/src/index-html.ts b/packages/bundler/src/index-html.tsindex c04707a579..1e8bb6f205 100644--- a/packages/bundler/src/index-html.ts+++ b/packages/bundler/src/index-html.ts@@ -11,7 +11,7 @@ export type RenderDefaults = {muted: boolean;maxConcurrency: number;stillImageFormat: 'png' | 'jpeg' | 'webp' | 'pdf';- videoImageFormat: 'png' | 'jpeg';+ videoImageFormat: 'png' | 'jpeg' | 'none';audioCodec: string | null;enforceAudioTrack: boolean;proResProfile: string;diff --git a/packages/cli/src/editor/components/RenderModal/human-readable-codec.ts b/packages/cli/src/editor/components/RenderModal/human-readable-codec.tsindex ab395ce7b8..2ad35d2c1f 100644--- a/packages/cli/src/editor/components/RenderModal/human-readable-codec.ts+++ b/packages/cli/src/editor/components/RenderModal/human-readable-codec.ts@@ -18,7 +18,7 @@ export const humanReadableCodec = (codec: Codec) => {}if (codec === 'h264-mkv') {- return 'H.264 MKV';+ return 'H.264 Matroska';}if (codec === 'h265') {diff --git a/packages/cli/src/preview-server/routes.ts b/packages/cli/src/preview-server/routes.tsindex e8653613d7..7e04a563ef 100644--- a/packages/cli/src/preview-server/routes.ts+++ b/packages/cli/src/preview-server/routes.ts@@ -71,8 +71,6 @@ const handleFallback = async ({const concurrency = RenderInternals.getActualConcurrency(ConfigInternals.getConcurrency());- const imageFormat = ConfigInternals.getUserPreferredStillImageFormat();- // TODO: ADD videoImageFormat = getUserPreferredVideoImageFormat()const muted = ConfigInternals.getMuted();const enforceAudioTrack = ConfigInternals.getEnforceAudioTrack();const pixelFormat = ConfigInternals.getPixelFormat();@@ -83,12 +81,8 @@ const handleFallback = async ({const numberOfGifLoops = ConfigInternals.getNumberOfGifLoops();const delayRenderTimeout = ConfigInternals.getCurrentPuppeteerTimeout();const audioCodec = ConfigInternals.getAudioCodec();-- // TODO: Separate image and video formats in the future. Default should be PNG for images and JPEG for videos.- const stillImageFormat: 'png' | 'jpeg' =- imageFormat === 'jpeg' || imageFormat === 'png' ? imageFormat : 'png';- const videoImageFormat =- imageFormat === 'jpeg' || imageFormat === 'png' ? imageFormat : 'jpeg';+ const stillImageFormat = ConfigInternals.getUserPreferredStillImageFormat();+ const videoImageFormat = ConfigInternals.getUserPreferredVideoImageFormat();const maxConcurrency = RenderInternals.getMaxConcurrency();const minConcurrency = RenderInternals.getMinConcurrency();@@ -123,8 +117,10 @@ const handleFallback = async ({concurrency,maxConcurrency,minConcurrency,- stillImageFormat,- videoImageFormat,+ stillImageFormat:+ stillImageFormat ?? RenderInternals.DEFAULT_STILL_IMAGE_FORMAT,+ videoImageFormat:+ videoImageFormat ?? RenderInternals.DEFAULT_VIDEO_IMAGE_FORMAT,muted,enforceAudioTrack,proResProfile,diff --git a/packages/renderer/src/image-format.ts b/packages/renderer/src/image-format.tsindex b361086a4c..84288bb268 100644--- a/packages/renderer/src/image-format.ts+++ b/packages/renderer/src/image-format.ts@@ -9,7 +9,8 @@ export const validStillImageFormats = ['png', 'jpeg', 'pdf', 'webp'] as const;export type VideoImageFormat = typeof validVideoImageFormats[number];export type StillImageFormat = typeof validStillImageFormats[number];-export const DEFAULT_IMAGE_FORMAT: VideoImageFormat = 'jpeg';+export const DEFAULT_VIDEO_IMAGE_FORMAT: VideoImageFormat = 'jpeg';+export const DEFAULT_STILL_IMAGE_FORMAT: StillImageFormat = 'png';// By returning a value, we improve testability as we can specifically test certain branchesexport const validateSelectedPixelFormatAndImageFormatCombination = (diff --git a/packages/renderer/src/index.ts b/packages/renderer/src/index.tsindex 5becc5fc07..358a078c65 100644--- a/packages/renderer/src/index.ts+++ b/packages/renderer/src/index.ts@@ -33,7 +33,12 @@ import {getExtensionOfFilename} from './get-extension-of-filename';import {getRealFrameRange} from './get-frame-to-render';import {ensureLocalBrowser} from './get-local-browser-executable';import {getDesiredPort} from './get-port';-import {validStillImageFormats, validVideoImageFormats} from './image-format';+import {+ DEFAULT_STILL_IMAGE_FORMAT,+ DEFAULT_VIDEO_IMAGE_FORMAT,+ validStillImageFormats,+ validVideoImageFormats,+} from './image-format';import {isAudioCodec} from './is-audio-codec';import {isServeUrl} from './is-serve-url';import {isEqualOrBelowLogLevel, isValidLogLevel, logLevels} from './log-level';@@ -165,6 +170,8 @@ export const RenderInternals = {callFfExtraOptions,validStillImageFormats,validVideoImageFormats,+ DEFAULT_STILL_IMAGE_FORMAT,+ DEFAULT_VIDEO_IMAGE_FORMAT,};// Warn of potential performance issues with Apple Silicon (M1 chip under Rosetta)diff --git a/packages/renderer/src/render-frames.ts b/packages/renderer/src/render-frames.tsindex 68171ea1d0..24a6406945 100644--- a/packages/renderer/src/render-frames.ts+++ b/packages/renderer/src/render-frames.ts@@ -28,7 +28,7 @@ import {} from './get-frame-padded-index';import {getRealFrameRange} from './get-frame-to-render';import type {VideoImageFormat} from './image-format';-import {DEFAULT_IMAGE_FORMAT} from './image-format';+import {DEFAULT_VIDEO_IMAGE_FORMAT} from './image-format';import type {CancelSignal} from './make-cancel-signal';import {cancelErrorMessages, isUserCancelledRender} from './make-cancel-signal';import type {ChromiumOptions} from './open-browser';@@ -90,7 +90,7 @@ const innerRenderFrames = ({onStart,inputProps,quality,- imageFormat = DEFAULT_IMAGE_FORMAT,+ imageFormat = DEFAULT_VIDEO_IMAGE_FORMAT,frameRange,onError,envVariables,diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.tsindex 13d55b5b59..1b63f66682 100644--- a/packages/renderer/src/render-still.ts+++ b/packages/renderer/src/render-still.ts@@ -13,7 +13,10 @@ import {ensureOutputDirectory} from './ensure-output-directory';import {handleJavascriptException} from './error-handling/handle-javascript-exception';import {findRemotionRoot} from './find-closest-package-json';import type {StillImageFormat} from './image-format';-import {validateStillImageFormat} from './image-format';+import {+ DEFAULT_STILL_IMAGE_FORMAT,+ validateStillImageFormat,+} from './image-format';import type {CancelSignal} from './make-cancel-signal';import {cancelErrorMessages} from './make-cancel-signal';import type {ChromiumOptions} from './open-browser';@@ -60,7 +63,7 @@ export type RenderStillOptions = InnerStillOptions & {const innerRenderStill = async ({composition,quality,- imageFormat = 'png',+ imageFormat = DEFAULT_STILL_IMAGE_FORMAT,serveUrl,puppeteerInstance,dumpBrowserLogs = false,