import type { InputAudioTrack, InputFormat, InputVideoTrack, MetadataTags, } from 'mediabunny'; import React from 'react'; import {Table, TableBody, TableCell, TableRow} from '@/components/ui/table'; import type {Dimensions} from '~/lib/calculate-new-dimensions-from-dimensions'; import {formatBytes} from '~/lib/format-bytes'; import {formatSeconds} from '~/lib/format-seconds'; import { renderHumanReadableAudioCodec, renderHumanReadableVideoCodec, } from '~/lib/render-codec-label'; import {MetadataDisplay} from './MetadataTable'; import {Skeleton} from './ui/skeleton'; export const ContainerOverview: React.FC<{ readonly dimensions: Dimensions | null | undefined; readonly durationInSeconds: number | null | undefined; readonly videoCodec: InputVideoTrack['codec'] | null; readonly audioCodec: InputAudioTrack['codec'] | null | undefined; readonly size: number | null; readonly fps: number | null | undefined; readonly container: InputFormat | null; readonly isHdr: boolean | undefined; readonly metadata: MetadataTags | null; readonly isAudioOnly: boolean; readonly sampleRate: number | null; }> = ({ container, dimensions, videoCodec, durationInSeconds, audioCodec, size, fps, isHdr, metadata, isAudioOnly, sampleRate, }) => { return ( Container {container ? ( container.name ) : ( )} Size {size === null ? ( ) : ( <>{formatBytes(size)} )} Duration {durationInSeconds === undefined ? ( ) : durationInSeconds === null ? ( N/A ) : ( <>{formatSeconds(durationInSeconds)} )} {!isAudioOnly && ( Dimensions {dimensions === undefined ? ( ) : dimensions === null ? ( <>N/A ) : ( <> {dimensions.width}x{dimensions.height} )} )} {isAudioOnly ? null : ( Frame Rate {fps === undefined ? ( ) : fps ? ( <>{fps.toFixed(2)} FPS ) : ( 'N/A' )} )} {isAudioOnly ? null : ( Video Codec {videoCodec === undefined ? ( ) : videoCodec === null ? ( <>N/A ) : ( renderHumanReadableVideoCodec(videoCodec) )} )} Audio Codec {audioCodec === undefined ? ( ) : audioCodec === null ? ( 'No audio' ) : ( renderHumanReadableAudioCodec(audioCodec) )} {sampleRate !== null ? ( Sample Rate {sampleRate} Hz ) : null} {isAudioOnly ? null : ( HDR {isHdr === undefined ? ( ) : isHdr ? ( 'Yes' ) : ( 'No' )} )} {metadata ? : null}
); };