Skip to content

🎥 Make videos programmatically with React

don't use render internals

Jonny Burgereefcaabb754a
diff --git a/packages/renderer/src/assets/get-video-stream-duration.ts b/packages/renderer/src/assets/get-video-stream-duration.ts
index 2f86fa09ac..6397bc9af4 100644
--- a/packages/renderer/src/assets/get-video-stream-duration.ts
+++ b/packages/renderer/src/assets/get-video-stream-duration.ts
@@ -1,4 +1,4 @@
-import {RenderInternals} from '..';
+import {callFf} from '../call-ffmpeg';
import {pLimit} from '../p-limit';
import type {DownloadMap, VideoDurationResult} from './download-map';
@@ -57,7 +57,7 @@ export async function getVideoStreamDurationwithoutCache({src}: {src: string}) {
.reduce<(string | null)[]>((acc, val) => acc.concat(val), [])
.filter(Boolean) as string[];
- const task = await RenderInternals.callFf('ffprobe', args);
+ const task = await callFf('ffprobe', args);
const result: VideoDurationResult = parseVideoStreamDuration(task.stdout);
diff --git a/packages/renderer/src/convert-to-pcm.ts b/packages/renderer/src/convert-to-pcm.ts
index c428fafe0b..40cc3f9eee 100644
--- a/packages/renderer/src/convert-to-pcm.ts
+++ b/packages/renderer/src/convert-to-pcm.ts
@@ -1,4 +1,4 @@
-import {RenderInternals} from '.';
+import {callFf} from './call-ffmpeg';
import {DEFAULT_SAMPLE_RATE} from './sample-rate';
export const convertToPcm = async ({
@@ -8,7 +8,7 @@ export const convertToPcm = async ({
input: string;
outName: string;
}) => {
- await RenderInternals.callFf('ffmpeg', [
+ await callFf('ffmpeg', [
'-i',
input,
'-c:a',
diff --git a/packages/renderer/src/create-silent-audio.ts b/packages/renderer/src/create-silent-audio.ts
index da474a6c52..3fd529c67b 100644
--- a/packages/renderer/src/create-silent-audio.ts
+++ b/packages/renderer/src/create-silent-audio.ts
@@ -1,4 +1,4 @@
-import {RenderInternals} from '.';
+import {callFf} from './call-ffmpeg';
import {DEFAULT_SAMPLE_RATE} from './sample-rate';
export const createSilentAudio = async ({
@@ -8,7 +8,7 @@ export const createSilentAudio = async ({
numberOfSeconds: number;
outName: string;
}) => {
- await RenderInternals.callFf('ffmpeg', [
+ await callFf('ffmpeg', [
'-f',
'lavfi',
'-i',
diff --git a/packages/renderer/src/ensure-presentation-timestamp.ts b/packages/renderer/src/ensure-presentation-timestamp.ts
index 832e22e0c0..9c4a48c926 100644
--- a/packages/renderer/src/ensure-presentation-timestamp.ts
+++ b/packages/renderer/src/ensure-presentation-timestamp.ts
@@ -1,6 +1,6 @@
import path from 'path';
-import {RenderInternals} from '.';
import type {DownloadMap} from './assets/download-map';
+import {callFf} from './call-ffmpeg';
import {guessExtensionForVideo} from './guess-extension-for-media';
import {truthy} from './truthy';
@@ -44,7 +44,7 @@ export const ensurePresentationTimestampWithoutCache = async ({
src,
});
- await RenderInternals.callFf('ffmpeg', [
+ await callFf('ffmpeg', [
'-i',
src,
'-fflags',
diff --git a/packages/renderer/src/extract-frame-from-video.ts b/packages/renderer/src/extract-frame-from-video.ts
index 87648a2ba0..96b26c3d40 100644
--- a/packages/renderer/src/extract-frame-from-video.ts
+++ b/packages/renderer/src/extract-frame-from-video.ts
@@ -1,7 +1,7 @@
import type {OffthreadVideoImageFormat} from 'remotion';
-import {RenderInternals} from '.';
import type {DownloadMap} from './assets/download-map';
import {getVideoStreamDuration} from './assets/get-video-stream-duration';
+import {callFf} from './call-ffmpeg';
import {determineResizeParams} from './determine-resize-params';
import {determineVcodecFfmpegFlags} from './determine-vcodec-ffmpeg-flags';
import {ensurePresentationTimestamps} from './ensure-presentation-timestamp';
@@ -145,7 +145,7 @@ const extractFrameFromVideoFn = async ({
}
const ffmpegTimestamp = frameToFfmpegTimestamp(time);
- const {stdout, stderr} = RenderInternals.callFf(
+ const {stdout, stderr} = callFf(
'ffmpeg',
[
'-ss',
diff --git a/packages/renderer/src/get-frame-of-video-slow.ts b/packages/renderer/src/get-frame-of-video-slow.ts
index 49ac52c9ab..e2ecd6d804 100644
--- a/packages/renderer/src/get-frame-of-video-slow.ts
+++ b/packages/renderer/src/get-frame-of-video-slow.ts
@@ -1,8 +1,8 @@
// Uses no seeking, therefore the whole video has to be decoded. This is a last resort and should only happen
// if the video is corrupted
import type {OffthreadVideoImageFormat} from 'remotion';
-import {RenderInternals} from '.';
import type {SpecialVCodecForTransparency} from './assets/download-map';
+import {callFf} from './call-ffmpeg';
import {determineResizeParams} from './determine-resize-params';
import {determineVcodecFfmpegFlags} from './determine-vcodec-ffmpeg-flags';
import {truthy} from './truthy';
@@ -44,7 +44,7 @@ export const getFrameOfVideoSlow = async ({
'-',
].filter(truthy);
- const {stdout, stderr} = RenderInternals.callFf('ffmpeg', command);
+ const {stdout, stderr} = callFf('ffmpeg', command);
if (!stderr) {
throw new Error('unexpectedly did not get stderr');
diff --git a/packages/renderer/src/get-video-info.ts b/packages/renderer/src/get-video-info.ts
index e989e4fa1b..57975e4c69 100644
--- a/packages/renderer/src/get-video-info.ts
+++ b/packages/renderer/src/get-video-info.ts
@@ -1,6 +1,6 @@
-import {RenderInternals} from '.';
import type {DownloadMap, Vp9Result} from './assets/download-map';
import {calculateDisplayVideoSize} from './calculate-sar-dar-pixels';
+import {callFf} from './call-ffmpeg';
import {pLimit} from './p-limit';
const limit = pLimit(1);
@@ -10,7 +10,7 @@ export async function getVideoInfoUncached({
}: {
src: string;
}): Promise<Vp9Result> {
- const task = await RenderInternals.callFf('ffprobe', [src]);
+ const task = await callFf('ffprobe', [src]);
const isVp9 = task.stderr.includes('Video: vp9');
const isVp8 = task.stderr.includes('Video: vp8');
diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.ts
index f865e55af1..0baa53e456 100644
--- a/packages/renderer/src/stitch-frames-to-video.ts
+++ b/packages/renderer/src/stitch-frames-to-video.ts
@@ -2,7 +2,6 @@ import fs, {promises} from 'fs';
import path from 'path';
import type {TAsset} from 'remotion';
import {Internals} from 'remotion';
-import {RenderInternals} from '.';
import {calculateAssetPositions} from './assets/calculate-asset-positions';
import {convertAssetsToFileUrls} from './assets/convert-assets-to-file-urls';
import type {RenderMediaOnDownload} from './assets/download-and-map-assets-to-file';
@@ -393,7 +392,7 @@ export const spawnFfmpeg = async (
console.log(finalFfmpegString);
}
- const task = RenderInternals.callFf('ffmpeg', finalFfmpegString, {
+ const task = callFf('ffmpeg', finalFfmpegString, {
cwd: options.dir,
});
options.cancelSignal?.(() => {
diff --git a/packages/renderer/src/try-to-extract-frame-of-video-fast.ts b/packages/renderer/src/try-to-extract-frame-of-video-fast.ts
index 90dbb6a37d..fc471264e0 100644
--- a/packages/renderer/src/try-to-extract-frame-of-video-fast.ts
+++ b/packages/renderer/src/try-to-extract-frame-of-video-fast.ts
@@ -1,9 +1,9 @@
import type {OffthreadVideoImageFormat} from 'remotion';
-import {RenderInternals} from '.';
import type {
NeedsResize,
SpecialVCodecForTransparency,
} from './assets/download-map';
+import {callFf} from './call-ffmpeg';
import {determineResizeParams} from './determine-resize-params';
import {determineVcodecFfmpegFlags} from './determine-vcodec-ffmpeg-flags';
import {truthy} from './truthy';
@@ -21,7 +21,7 @@ export const tryToExtractFrameOfVideoFast = async ({
specialVCodecForTransparency: SpecialVCodecForTransparency;
actualOffset: string;
}) => {
- const {stdout, stderr} = RenderInternals.callFf(
+ const {stdout, stderr} = callFf(
'ffmpeg',
[
'-ss',