Skip to content

🎥 Make videos programmatically with React

remove thumbnails for now

Jonny Burger9f10d8dc1cc8
diff --git a/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx b/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx
index c12980d0b2..dc9951824c 100644
--- a/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx
+++ b/packages/cli/src/editor/components/Timeline/TimelineSequence.tsx
@@ -65,9 +65,7 @@ export const TimelineSequence: React.FC<{
const thumbnailWidth = TIMELINE_LAYER_HEIGHT * (video.width / video.height);
- const thumbnailFit = !Internals.FEATURE_FLAG_RICH_PREVIEWS
- ? 1
- : Math.ceil(width / thumbnailWidth);
+ const thumbnailFit = !Internals.FEATURE_FLAG_RICH_PREVIEWS ? 0 : 1;
return (
<div key={s.id} style={style} title={s.displayName}>
diff --git a/packages/renderer/src/assets/convert-assets-to-file-urls.ts b/packages/renderer/src/assets/convert-assets-to-file-urls.ts
index 8c2fcf0547..3d00a1d613 100644
--- a/packages/renderer/src/assets/convert-assets-to-file-urls.ts
+++ b/packages/renderer/src/assets/convert-assets-to-file-urls.ts
@@ -4,9 +4,11 @@ import {downloadAndMapAssetsToFileUrl} from './download-and-map-assets-to-file';
export const convertAssetsToFileUrls = ({
assets,
dir,
+ localPort,
}: {
assets: TAsset[][];
dir: string;
+ localPort: number;
}): Promise<TAsset[][]> => {
return Promise.all(
assets.map((assetsForFrame) => {
@@ -15,6 +17,7 @@ export const convertAssetsToFileUrls = ({
return downloadAndMapAssetsToFileUrl({
localhostAsset: a,
webpackBundle: dir,
+ localPort,
});
})
);
diff --git a/packages/renderer/src/assets/download-and-map-assets-to-file.ts b/packages/renderer/src/assets/download-and-map-assets-to-file.ts
index 5b5c5dbb1e..d2b0023569 100644
--- a/packages/renderer/src/assets/download-and-map-assets-to-file.ts
+++ b/packages/renderer/src/assets/download-and-map-assets-to-file.ts
@@ -9,7 +9,8 @@ const isDownloadingMap: {[key: string]: boolean} = {};
const hasBeenDownloadedMap: {[key: string]: boolean} = {};
const listeners: {[key: string]: (() => void)[]} = {};
-const isRemoteAsset = (asset: string) => !asset.startsWith('http://localhost');
+const isRemoteAsset = (asset: string, localPort: number) =>
+ !asset.startsWith(`http://localhost:${localPort}`);
const pipeline = promisify(stream.pipeline);
@@ -52,13 +53,15 @@ const downloadAsset = async (src: string, to: string) => {
export const downloadAndMapAssetsToFileUrl = async ({
localhostAsset,
webpackBundle,
+ localPort,
}: {
localhostAsset: TAsset;
webpackBundle: string;
+ localPort: number;
}): Promise<TAsset> => {
const {pathname} = new URL(localhostAsset.src);
const newSrc = path.join(webpackBundle, pathname);
- if (isRemoteAsset(localhostAsset.src)) {
+ if (isRemoteAsset(localhostAsset.src, localPort)) {
await downloadAsset(localhostAsset.src, newSrc);
}
return {
diff --git a/packages/renderer/src/render.ts b/packages/renderer/src/render.ts
index 3dbb0b2882..1df96fac64 100644
--- a/packages/renderer/src/render.ts
+++ b/packages/renderer/src/render.ts
@@ -17,6 +17,7 @@ import {serveStatic} from './serve-static';
export type RenderFramesOutput = {
frameCount: number;
assetsInfo: RenderAssetInfo;
+ localPort: number;
};
type OnStartData = {
@@ -129,5 +130,6 @@ export const renderFrames = async ({
bundleDir: webpackBundle,
},
frameCount,
+ localPort: port,
};
};
diff --git a/packages/renderer/src/stitcher.ts b/packages/renderer/src/stitcher.ts
index 4dd83f0eb0..048c4a0984 100644
--- a/packages/renderer/src/stitcher.ts
+++ b/packages/renderer/src/stitcher.ts
@@ -41,6 +41,7 @@ export const stitchFramesToVideo = async (options: {
assetsInfo: RenderAssetInfo;
parallelism?: number | null;
onProgress?: (num: number) => void;
+ localPort: number;
}): Promise<void> => {
const codec = options.codec ?? Internals.DEFAULT_CODEC;
const crf = options.crf ?? Internals.getDefaultCrfForCodec(codec);
@@ -69,6 +70,7 @@ export const stitchFramesToVideo = async (options: {
const fileUrlAssets = await convertAssetsToFileUrls({
assets: options.assetsInfo.assets,
dir: options.assetsInfo.bundleDir,
+ localPort: options.localPort,
});
const assetPositions = calculateAssetPositions(fileUrlAssets);
diff --git a/packages/renderer/src/test/map-localhost-to-file.test.ts b/packages/renderer/src/test/map-localhost-to-file.test.ts
index a96c1eb5ef..6e6e4ef427 100644
--- a/packages/renderer/src/test/map-localhost-to-file.test.ts
+++ b/packages/renderer/src/test/map-localhost-to-file.test.ts
@@ -11,6 +11,7 @@ test('Should correctly map a localhost URL to an asset', async () => {
sequenceFrame: 2045,
volume: 1,
},
+ localPort: 3000,
webpackBundle:
'/var/folders/hl/p8pg9kw15dbg3l7dbpn0scc80000gn/T/react-motion-graphicstoSTC7',
})