Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderMedia() - new disallowParallelEncoding option #1386

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/docs/docs/renderer/render-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ Using this feature is discouraged. Before using it, we want to make you aware of
Before you use this hack, reach out to the Remotion team on [Discord](https://remotion.dev/discord) and ask us if we are open to implement the feature you need in a clean way - we often do implement new features quickly based on users feedback.
:::

### `disallowParallelEncoding`

_available from v3.2.29_

Disallows the renderer from doing rendering frames and encoding at the same time. This makes the rendering process more memory-efficient, but possibly slower.

## See also

- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/renderer/src/render-media.ts)
Expand Down
12 changes: 10 additions & 2 deletions packages/renderer/src/render-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export type RenderMediaOptions = {
muted?: boolean;
enforceAudioTrack?: boolean;
ffmpegOverride?: FfmpegOverrideFn;
disallowParallelEncoding?: boolean;
} & ServeUrlOrWebpackBundle &
ConcurrencyOrParallelism;

Expand Down Expand Up @@ -195,7 +196,10 @@ export const renderMedia = ({
height: composition.height,
width: composition.width,
});
const parallelEncoding = hasEnoughMemory && canUseParallelEncoding(codec);
const parallelEncoding =
!options.disallowParallelEncoding &&
hasEnoughMemory &&
canUseParallelEncoding(codec);

if (options.verbose) {
console.log(
Expand All @@ -205,9 +209,13 @@ export const renderMedia = ({
estimatedUsage
);
console.log(
'[PRESTICHER]: Codec supports parallel rendering:',
'[PRESTITCHER]: Codec supports parallel rendering:',
canUseParallelEncoding(codec)
);
console.log(
'[PRESTITCHER]: User disallowed parallel encoding:',
Boolean(options.disallowParallelEncoding)
);
if (parallelEncoding) {
console.log('[PRESTITCHER] Parallel encoding is enabled.');
} else {
Expand Down