🎥 Make videos programmatically with React
remove more stuff that is not needed
Jonny Burger13a1d5106a74
diff --git a/packages/docs/docs/4-0-migration.md b/packages/docs/docs/4-0-migration.mdindex d40121f055..450109cb07 100644--- a/packages/docs/docs/4-0-migration.md+++ b/packages/docs/docs/4-0-migration.md@@ -127,3 +127,5 @@ const tangent = getTangentAtLength(parts[0], length / 2);The `onBucketEnsured()` option of [`getOrCreateBucket`](/docs/lambda/getorcreatebucket) has been removed because creating the bucket is the only operation of `getOrCreateBucket()`. Therefore, you can just await the function itself.## `imageFormat` removed from `<OffthreadVideo>`++## `OffthreadVideoImageFormat` removeddiff --git a/packages/renderer/src/assets/download-map.ts b/packages/renderer/src/assets/download-map.tsindex be080825f1..7b064213c1 100644--- a/packages/renderer/src/assets/download-map.ts+++ b/packages/renderer/src/assets/download-map.ts@@ -4,11 +4,6 @@ import type {TAsset} from 'remotion';import {deleteDirectory} from '../delete-directory';import {tmpDir} from '../tmp-dir';-export type VideoDurationResult = {- duration: number | null;- fps: number | null;-};-export type AudioChannelsAndDurationResultCache = {channels: number;duration: number | null;@@ -31,7 +26,6 @@ export type DownloadMap = {| undefined;};listeners: {[key: string]: {[downloadDir: string]: (() => void)[]}};- videoDurationResultCache: Record<string, VideoDurationResult>;durationOfAssetCache: Record<string, AudioChannelsAndDurationResultCache>;downloadDir: string;preEncode: string;@@ -74,7 +68,6 @@ export const makeDownloadMap = (): DownloadMap => {isDownloadingMap: {},hasBeenDownloadedMap: {},listeners: {},- videoDurationResultCache: {},durationOfAssetCache: {},id: String(Math.random()),assetDir: dir,diff --git a/packages/renderer/src/assets/get-video-stream-duration.ts b/packages/renderer/src/assets/get-video-stream-duration.tsdeleted file mode 100644index 6397bc9af4..0000000000--- a/packages/renderer/src/assets/get-video-stream-duration.ts+++ /dev/null@@ -1,89 +0,0 @@-import {callFf} from '../call-ffmpeg';-import {pLimit} from '../p-limit';-import type {DownloadMap, VideoDurationResult} from './download-map';--const limit = pLimit(1);--const parseAlternativeDuration = (stdout: string): number | null => {- const webmDuration = stdout.match(- /TAG:DURATION=([0-9.]+):([0-9.]+):([0-9.]+)/- );- if (!webmDuration) {- return null;- }-- const [, hours, minutes, seconds] = webmDuration;-- const hoursAsNumber = Number(hours);-- if (Number.isNaN(hoursAsNumber)) {- return null;- }-- const minutesAsNumber = Number(minutes);-- if (Number.isNaN(minutesAsNumber)) {- return null;- }-- const secondsAsNumber = Number(seconds);- if (Number.isNaN(secondsAsNumber)) {- return null;- }-- return secondsAsNumber + minutesAsNumber * 60 + hoursAsNumber * 3600;-};--export const parseVideoStreamDuration = (stdout: string) => {- const duration = stdout.match(/duration=([0-9.]+)/);- const alternativeDuration = parseAlternativeDuration(stdout);- const fps = stdout.match(/r_frame_rate=([0-9.]+)\/([0-9.]+)/);-- const result: VideoDurationResult = {- duration: duration ? parseFloat(duration[1]) : alternativeDuration,- fps: fps ? parseInt(fps[1], 10) / parseInt(fps[2], 10) : null,- };-- return result;-};--export async function getVideoStreamDurationwithoutCache({src}: {src: string}) {- const args = [- ['-v', 'error'],- ['-select_streams', 'v:0'],- ['-show_entries', 'stream'],- [src],- ]- .reduce<(string | null)[]>((acc, val) => acc.concat(val), [])- .filter(Boolean) as string[];-- const task = await callFf('ffprobe', args);-- const result: VideoDurationResult = parseVideoStreamDuration(task.stdout);-- return result;-}--async function getVideoStreamDurationUnlimited(- downloadMap: DownloadMap,- src: string-): Promise<VideoDurationResult> {- if (downloadMap.videoDurationResultCache[src]) {- return downloadMap.videoDurationResultCache[src];- }-- const result: VideoDurationResult = await getVideoStreamDurationwithoutCache({- src,- });-- downloadMap.videoDurationResultCache[src] = result;-- return result;-}--export const getVideoStreamDuration = (- downloadMap: DownloadMap,- src: string-): Promise<VideoDurationResult> => {- return limit(() => getVideoStreamDurationUnlimited(downloadMap, src));-};diff --git a/packages/renderer/src/test/parse-video-stream-duration.test.ts b/packages/renderer/src/test/parse-video-stream-duration.test.tsdeleted file mode 100644index 0ac86b92f8..0000000000--- a/packages/renderer/src/test/parse-video-stream-duration.test.ts+++ /dev/null@@ -1,89 +0,0 @@-import {expect, test} from 'vitest';-import {parseVideoStreamDuration} from '../assets/get-video-stream-duration';--test('Parse video stream duration', () => {- const result = parseVideoStreamDuration(- `-[STREAM]-index=0-codec_name=vp9-codec_long_name=Google VP9-profile=Profile 0-codec_type=video-codec_tag_string=[0][0][0][0]-codec_tag=0x0000-width=1920-height=1080-coded_width=1920-coded_height=1080-closed_captions=0-film_grain=0-has_b_frames=0-sample_aspect_ratio=1:1-display_aspect_ratio=16:9-pix_fmt=yuv420p-level=-99-color_range=tv-color_space=unknown-color_transfer=unknown-color_primaries=unknown-chroma_location=left-field_order=progressive-refs=1-id=N/A-r_frame_rate=2499/100-avg_frame_rate=2499/100-time_base=1/1000-start_pts=6-start_time=0.006000-duration_ts=N/A-duration=N/A-bit_rate=N/A-max_bit_rate=N/A-bits_per_raw_sample=N/A-nb_frames=N/A-nb_read_frames=N/A-nb_read_packets=N/A-DISPOSITION:default=1-DISPOSITION:dub=0-DISPOSITION:original=0-DISPOSITION:comment=0-DISPOSITION:lyrics=0-DISPOSITION:karaoke=0-DISPOSITION:forced=0-DISPOSITION:hearing_impaired=0-DISPOSITION:visual_impaired=0-DISPOSITION:clean_effects=0-DISPOSITION:attached_pic=0-DISPOSITION:timed_thumbnails=0-DISPOSITION:captions=0-DISPOSITION:descriptions=0-DISPOSITION:metadata=0-DISPOSITION:dependent=0-DISPOSITION:still_image=0-TAG:ALPHA_MODE=1-TAG:ENCODER=Lavc58.134.100 libvpx-vp9-TAG:DURATION=01:20:05.008000000-[/STREAM]- `.trim()- );- expect(result).toEqual({- fps: 24.99,- duration: 4805.008,- });-});--test('Parse video stream duration 2', () => {- const result = parseVideoStreamDuration(- `-[STREAM]-r_frame_rate=2499/100-duration=5.0080000-[/STREAM]- `.trim()- );- expect(result).toEqual({- fps: 24.99,- duration: 5.008,- });-});