Skip to content

🎥 Make videos programmatically with React

better metadata

Jonny Burger7ec8eb6e4bc8
diff --git a/packages/convert/app/components/ContainerOverview.tsx b/packages/convert/app/components/ContainerOverview.tsx
index adcbad098d..88c1889c96 100644
--- a/packages/convert/app/components/ContainerOverview.tsx
+++ b/packages/convert/app/components/ContainerOverview.tsx
@@ -29,6 +29,7 @@ export const ContainerOverview: React.FC<{
readonly isHdr: boolean | undefined;
readonly metadata: MetadataEntry[] | null;
readonly location: MediaParserLocation | null;
+ isAudioOnly: boolean;
}> = ({
container,
dimensions,
@@ -40,6 +41,7 @@ export const ContainerOverview: React.FC<{
isHdr,
metadata,
location,
+ isAudioOnly,
}) => {
return (
<Table className="table-fixed">
@@ -76,44 +78,50 @@ export const ContainerOverview: React.FC<{
)}
</TableCell>
</TableRow>
- <TableRow>
- <TableCell className="font-brand">Dimensions</TableCell>
- <TableCell className="text-right">
- {dimensions === undefined ? (
- <Skeleton className="h-3 w-[100px] inline-block" />
- ) : dimensions === null ? (
- <>N/A</>
- ) : (
- <>
- {dimensions.width}x{dimensions.height}
- </>
- )}
- </TableCell>
- </TableRow>
- <TableRow>
- <TableCell className="font-brand">Frame Rate</TableCell>
- <TableCell className="text-right">
- {fps === undefined ? (
- <Skeleton className="h-3 w-[100px] inline-block" />
- ) : fps ? (
- <>{fps.toFixed(2)} FPS</>
- ) : (
- 'N/A'
- )}
- </TableCell>
- </TableRow>
- <TableRow>
- <TableCell className="font-brand">Video Codec</TableCell>
- <TableCell className="text-right">
- {videoCodec === undefined ? (
- <Skeleton className="h-3 w-[100px] inline-block" />
- ) : videoCodec === null ? (
- <>N/A</>
- ) : (
- renderHumanReadableVideoCodec(videoCodec)
- )}
- </TableCell>
- </TableRow>
+ {!isAudioOnly && (
+ <TableRow>
+ <TableCell className="font-brand">Dimensions</TableCell>
+ <TableCell className="text-right">
+ {dimensions === undefined ? (
+ <Skeleton className="h-3 w-[100px] inline-block" />
+ ) : dimensions === null ? (
+ <>N/A</>
+ ) : (
+ <>
+ {dimensions.width}x{dimensions.height}
+ </>
+ )}
+ </TableCell>
+ </TableRow>
+ )}
+ {isAudioOnly ? null : (
+ <TableRow>
+ <TableCell className="font-brand">Frame Rate</TableCell>
+ <TableCell className="text-right">
+ {fps === undefined ? (
+ <Skeleton className="h-3 w-[100px] inline-block" />
+ ) : fps ? (
+ <>{fps.toFixed(2)} FPS</>
+ ) : (
+ 'N/A'
+ )}
+ </TableCell>
+ </TableRow>
+ )}
+ {isAudioOnly ? null : (
+ <TableRow>
+ <TableCell className="font-brand">Video Codec</TableCell>
+ <TableCell className="text-right">
+ {videoCodec === undefined ? (
+ <Skeleton className="h-3 w-[100px] inline-block" />
+ ) : videoCodec === null ? (
+ <>N/A</>
+ ) : (
+ renderHumanReadableVideoCodec(videoCodec)
+ )}
+ </TableCell>
+ </TableRow>
+ )}
<TableRow>
<TableCell className="font-brand">Audio Codec</TableCell>
<TableCell className="text-right">
@@ -126,18 +134,20 @@ export const ContainerOverview: React.FC<{
)}
</TableCell>
</TableRow>
- <TableRow>
- <TableCell className="font-brand">HDR</TableCell>
- <TableCell className="text-right">
- {isHdr === undefined ? (
- <Skeleton className="h-3 w-[100px] inline-block" />
- ) : isHdr ? (
- 'Yes'
- ) : (
- 'No'
- )}
- </TableCell>
- </TableRow>
+ {isAudioOnly ? null : (
+ <TableRow>
+ <TableCell className="font-brand">HDR</TableCell>
+ <TableCell className="text-right">
+ {isHdr === undefined ? (
+ <Skeleton className="h-3 w-[100px] inline-block" />
+ ) : isHdr ? (
+ 'Yes'
+ ) : (
+ 'No'
+ )}
+ </TableCell>
+ </TableRow>
+ )}
<MetadataDisplay
location={location}
metadata={metadata ?? []}
diff --git a/packages/convert/app/components/Probe.tsx b/packages/convert/app/components/Probe.tsx
index f8f66a8f69..1e06dcaa38 100644
--- a/packages/convert/app/components/Probe.tsx
+++ b/packages/convert/app/components/Probe.tsx
@@ -2,6 +2,7 @@
import clsx from 'clsx';
import React, {useCallback, useMemo, useState} from 'react';
import type {Source} from '~/lib/convert-state';
+import {isAudioOnly} from '~/lib/is-audio-container';
import {useIsNarrow} from '~/lib/is-narrow';
import {
useAddFilenameToTitle,
@@ -87,6 +88,8 @@ export const Probe: React.FC<{
return sortedTracks[trackDetails];
}, [probeDetails, sortedTracks, trackDetails]);
+ const isAudio = isAudioOnly({tracks, container});
+
useAddFilenameToTitle(name);
useCopyThumbnailToFavicon(videoThumbnailRef);
@@ -146,6 +149,7 @@ export const Probe: React.FC<{
<ScrollArea height={300} className="flex-1">
{selectedTrack === null ? (
<ContainerOverview
+ isAudioOnly={isAudio}
container={container ?? null}
dimensions={dimensions ?? null}
videoCodec={videoCodec ?? null}
diff --git a/packages/convert/app/lib/is-audio-container.ts b/packages/convert/app/lib/is-audio-container.ts
new file mode 100644
index 0000000000..a4a7361e55
--- /dev/null
+++ b/packages/convert/app/lib/is-audio-container.ts
@@ -0,0 +1,15 @@
+import type {ParseMediaContainer, TracksField} from '@remotion/media-parser';
+
+export const isAudioOnly = ({
+ tracks,
+ container,
+}: {
+ tracks: TracksField | null;
+ container: ParseMediaContainer | null;
+}) => {
+ if (container === 'mp3') {
+ return true;
+ }
+
+ return (tracks && tracks.videoTracks.length === 0) ?? false;
+};
diff --git a/packages/convert/app/lib/render-metadata-label.ts b/packages/convert/app/lib/render-metadata-label.ts
index 3aaf2001a7..10d787fb2d 100644
--- a/packages/convert/app/lib/render-metadata-label.ts
+++ b/packages/convert/app/lib/render-metadata-label.ts
@@ -130,6 +130,38 @@ export const renderMetadataLabel = (key: string) => {
return 'Live Photo Auto Mode';
}
+ if (key === 'TPE1') {
+ return 'Artist';
+ }
+
+ if (key === 'TIT2') {
+ return 'Title';
+ }
+
+ if (key === 'TYER') {
+ return 'Year';
+ }
+
+ if (key === 'TCON') {
+ return 'Genre';
+ }
+
+ if (key === 'TCOM') {
+ return 'Composer';
+ }
+
+ if (key === 'TCMP') {
+ return 'Compilation';
+ }
+
+ if (key === 'TALB') {
+ return 'Album';
+ }
+
+ if (key === 'COMM') {
+ return 'Comment';
+ }
+
return key;
};
@@ -170,6 +202,14 @@ export const sortMetadataByRelevance = (metadata: MetadataEntry[]) => {
'minor_version',
'compatible_brands',
'handler_name',
+ 'TIT2',
+ 'TPE1',
+ 'TALB',
+ 'TCON',
+ 'TCOM',
+ 'TCMP',
+ 'COMM',
+ 'TYER',
];
return metadata.slice().sort((a, b) => {
@@ -247,6 +287,10 @@ export const renderMetadataValue = ({
return formatDateString(String(value));
}
+ if (key === 'TCMP') {
+ return value === '1' ? 'Yes' : 'No';
+ }
+
if (key === 'com.apple.quicktime.camera.focal_length.35mm_equivalent') {
return String(value) + 'mm';
}
diff --git a/packages/media-parser/src/boxes/mp3/id3.ts b/packages/media-parser/src/boxes/mp3/id3.ts
index 95d77a2bff..a068a0cadc 100644
--- a/packages/media-parser/src/boxes/mp3/id3.ts
+++ b/packages/media-parser/src/boxes/mp3/id3.ts
@@ -59,7 +59,7 @@ export const parseId3 = (iterator: BufferIterator, structure: Mp3Structure) => {
entries.push({
key: name,
value: information,
- trackId: 0,
+ trackId: null,
});
}