🎥 Make videos programmatically with React
make it make sense
Jonny Burger709534384a3c
diff --git a/packages/convert/app/components/AudioTrackOverview.tsx b/packages/convert/app/components/AudioTrackOverview.tsxindex e2974a8f9f..48c382b527 100644--- a/packages/convert/app/components/AudioTrackOverview.tsx+++ b/packages/convert/app/components/AudioTrackOverview.tsx@@ -1,45 +1,38 @@-import type {AudioTrack} from '@remotion/media-parser';+import type {AudioTrack, MetadataEntry} from '@remotion/media-parser';import {renderHumanReadableAudioCodec} from '~/lib/render-codec-label';+import {MetadataDisplay} from './MetadataTable';import {Table, TableBody, TableCell, TableRow} from './ui/table';export const AudioTrackOverview: React.FC<{readonly track: AudioTrack;-}> = ({track}) => {+ readonly metadata: MetadataEntry[] | null;+}> = ({track, metadata}) => {return (- <Table>+ <Table className="table-fixed"><TableBody><TableRow>- <TableCell className="font-brand" colSpan={3}>- Type- </TableCell>+ <TableCell className="font-brand">Type</TableCell><TableCell className="text-right">Audio</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Codec- </TableCell>+ <TableCell className="font-brand">Codec</TableCell><TableCell className="text-right">{renderHumanReadableAudioCodec(track.codecWithoutConfig)}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- WebCodecs Codec String- </TableCell>+ <TableCell className="font-brand">WebCodecs Codec String</TableCell><TableCell className="text-right">{track.codec}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Channels- </TableCell>+ <TableCell className="font-brand">Channels</TableCell><TableCell className="text-right">{track.numberOfChannels}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Sample Rate- </TableCell>+ <TableCell className="font-brand">Sample Rate</TableCell><TableCell className="text-right">{track.sampleRate}</TableCell></TableRow>+ <MetadataDisplay metadata={metadata ?? []} trackId={track.trackId} /></TableBody></Table>);diff --git a/packages/convert/app/components/ContainerOverview.tsx b/packages/convert/app/components/ContainerOverview.tsxindex 8193f6b9db..a104a092bd 100644--- a/packages/convert/app/components/ContainerOverview.tsx+++ b/packages/convert/app/components/ContainerOverview.tsx@@ -13,20 +13,9 @@ import {renderHumanReadableAudioCodec,renderHumanReadableVideoCodec,} from '~/lib/render-codec-label';-import {renderMetadataLabel} from '~/lib/render-metadata-label';+import {MetadataDisplay} from './MetadataTable';import {Skeleton} from './ui/skeleton';-const LimitedWidthLabel: React.FC<{- readonly children: React.ReactNode;- readonly alt: string;-}> = ({children, alt}) => {- return (- <div className="text-ellipsis break-words" title={alt}>- {children}- </div>- );-};-export const ContainerOverview: React.FC<{readonly dimensions: Dimensions | null;readonly durationInSeconds: number | null | undefined;@@ -141,20 +130,7 @@ export const ContainerOverview: React.FC<{)}</TableCell></TableRow>- {metadata?.map((entry) => (- <TableRow>- <TableCell className="font-brand">- <LimitedWidthLabel alt={entry.key}>- {renderMetadataLabel(entry.key)}- </LimitedWidthLabel>- </TableCell>- <TableCell className="text-right">- <LimitedWidthLabel alt={entry.key}>- {entry.value}- </LimitedWidthLabel>- </TableCell>- </TableRow>- ))}+ <MetadataDisplay metadata={metadata ?? []} trackId={null} /></TableBody></Table>);diff --git a/packages/convert/app/components/MetadataTable.tsx b/packages/convert/app/components/MetadataTable.tsxnew file mode 100644index 0000000000..179a77c8b9--- /dev/null+++ b/packages/convert/app/components/MetadataTable.tsx@@ -0,0 +1,43 @@+import {MetadataEntry} from '@remotion/media-parser';+import React, {useMemo} from 'react';+import {renderMetadataLabel} from '~/lib/render-metadata-label';+import {TableCell, TableRow} from './ui/table';++const LimitedWidthLabel: React.FC<{+ readonly children: React.ReactNode;+ readonly alt: string;+}> = ({children, alt}) => {+ return (+ <div className="text-ellipsis break-words" title={alt}>+ {children}+ </div>+ );+};++export const MetadataDisplay: React.FC<{+ readonly metadata: MetadataEntry[];+ readonly trackId: number | null;+}> = ({metadata, trackId}) => {+ const filtered = useMemo(() => {+ return metadata.filter((entry) => {+ return entry.trackId === trackId;+ });+ }, [metadata, trackId]);++ return (+ <>+ {filtered.map((entry) => (+ <TableRow>+ <TableCell className="font-brand">+ <LimitedWidthLabel alt={entry.key}>+ {renderMetadataLabel(entry.key)}+ </LimitedWidthLabel>+ </TableCell>+ <TableCell className="text-right">+ <LimitedWidthLabel alt={entry.key}>{entry.value}</LimitedWidthLabel>+ </TableCell>+ </TableRow>+ ))}+ </>+ );+};diff --git a/packages/convert/app/components/Probe.tsx b/packages/convert/app/components/Probe.tsxindex 18907ab600..025c097053 100644--- a/packages/convert/app/components/Probe.tsx+++ b/packages/convert/app/components/Probe.tsx@@ -138,9 +138,9 @@ export const Probe: React.FC<{isHdr={isHdr}/>) : selectedTrack.type === 'video' ? (- <VideoTrackOverview track={selectedTrack} />+ <VideoTrackOverview metadata={metadata} track={selectedTrack} />) : selectedTrack.type === 'audio' ? (- <AudioTrackOverview track={selectedTrack} />+ <AudioTrackOverview metadata={metadata} track={selectedTrack} />) : null}</ScrollArea><Separator orientation="horizontal" />diff --git a/packages/convert/app/components/VideoTrackOverview.tsx b/packages/convert/app/components/VideoTrackOverview.tsxindex b097698f4a..a8f459c744 100644--- a/packages/convert/app/components/VideoTrackOverview.tsx+++ b/packages/convert/app/components/VideoTrackOverview.tsx@@ -1,89 +1,71 @@import {Table, TableBody, TableCell, TableRow} from '@/components/ui/table';-import type {VideoTrack} from '@remotion/media-parser';+import type {MetadataEntry, VideoTrack} from '@remotion/media-parser';import React from 'react';import {renderHumanReadableVideoCodec} from '~/lib/render-codec-label';+import {MetadataDisplay} from './MetadataTable';export const VideoTrackOverview: React.FC<{readonly track: VideoTrack;-}> = ({track}) => {+ readonly metadata: MetadataEntry[] | null;+}> = ({track, metadata}) => {return (- <Table>+ <Table className="table-fixed"><TableBody><TableRow>- <TableCell className="font-brand" colSpan={3}>- Type- </TableCell>+ <TableCell className="font-brand">Type</TableCell><TableCell className="text-right">Video</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Codec- </TableCell>+ <TableCell className="font-brand">Codec</TableCell><TableCell className="text-right">{renderHumanReadableVideoCodec(track.codecWithoutConfig)}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- WebCodecs Codec String- </TableCell>+ <TableCell className="font-brand">WebCodecs Codec String</TableCell><TableCell className="text-right">{track.codec}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Dimensions- </TableCell>+ <TableCell className="font-brand">Dimensions</TableCell><TableCell className="text-right">{track.width}x{track.height}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Timescale- </TableCell>+ <TableCell className="font-brand">Timescale</TableCell><TableCell className="text-right">{track.timescale}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Sample Aspect Ratio- </TableCell>+ <TableCell className="font-brand">Sample Aspect Ratio</TableCell><TableCell className="text-right">{track.sampleAspectRatio.numerator}:{track.sampleAspectRatio.denominator}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Rotation- </TableCell>+ <TableCell className="font-brand">Rotation</TableCell><TableCell className="text-right">{track.rotation}°</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Unrotated dimensions- </TableCell>+ <TableCell className="font-brand">Unrotated dimensions</TableCell><TableCell className="text-right">{track.codedWidth}x{track.codedHeight}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Color Primaries- </TableCell>+ <TableCell className="font-brand">Color Primaries</TableCell><TableCell className="text-right">{track.color.primaries ?? 'N/A'}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Color Matrix- </TableCell>+ <TableCell className="font-brand">Color Matrix</TableCell><TableCell className="text-right">{track.color.matrixCoefficients ?? 'N/A'}</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>+ <TableCell className="font-brand">Color Transfer Characteristics</TableCell><TableCell className="text-right">@@ -91,9 +73,7 @@ export const VideoTrackOverview: React.FC<{</TableCell></TableRow><TableRow>- <TableCell className="font-brand" colSpan={3}>- Color Full Range- </TableCell>+ <TableCell className="font-brand">Color Full Range</TableCell><TableCell className="text-right">{track.color.fullRange? 'Yes'@@ -102,6 +82,7 @@ export const VideoTrackOverview: React.FC<{: 'N/A'}</TableCell></TableRow>+ <MetadataDisplay metadata={metadata ?? []} trackId={track.trackId} /></TableBody></Table>);