Skip to content

A self-hosted media server and file management system

feat: extended metadata based on ffprobe output

aminnausin536b2eeac1b6
diff --git a/resources/js/components/cards/data/attachments/FontCard.vue b/resources/js/components/cards/data/attachments/FontCard.vue
index 4c8626f4..a2bafcbb 100644
--- a/resources/js/components/cards/data/attachments/FontCard.vue
+++ b/resources/js/components/cards/data/attachments/FontCard.vue
@@ -2,13 +2,27 @@
import type { FontInfoResource } from '@/contracts/mediaInfo';
import { formatFileSize, toFormattedDate } from '@/service/util';
+import { ButtonCorner } from '@/components/cedar-ui/button';
+
+import TablerDownload from '@/components/icons/TablerDownload.vue';
defineProps<{ data: FontInfoResource }>();
</script>
<template>
- <div class="data-card text-foreground-2 w-full space-y-2 rounded-lg p-3 shadow-sm" v-if="data">
- <div class="space-y-1">
+ <div class="data-card bg-surface-2 text-foreground-2 w-full space-y-2 rounded-lg p-3 shadow-sm" v-if="data">
+ <div class="flex items-center justify-between">
<p class="text-foreground-0 truncate">{{ data.file_name }}</p>
+ <ButtonCorner
+ class="hover:text-primary dark:hover:text-primary-muted hover:dark:bg-surface-1 hover:bg-surface-6 size-6"
+ label="Download Font"
+ target="_blank"
+ :use-default-style="false"
+ :to="data.path"
+ >
+ <template #icon>
+ <TablerDownload class="size-4" />
+ </template>
+ </ButtonCorner>
</div>
<div class="flex shrink-0 justify-between">
<p>{{ formatFileSize(data.size) }}</p>
diff --git a/resources/js/components/cards/data/attachments/StreamInfoCard.vue b/resources/js/components/cards/data/attachments/StreamInfoCard.vue
new file mode 100644
index 00000000..518f54c7
--- /dev/null
+++ b/resources/js/components/cards/data/attachments/StreamInfoCard.vue
@@ -0,0 +1,17 @@
+<script setup lang="ts">
+import type { StreamField } from '@/service/media/ffprobe';
+
+const props = defineProps<{ title: string; fields: StreamField[] }>();
+</script>
+
+<template>
+ <div class="flex flex-col gap-1">
+ <p class="text-foreground-0">{{ title }}</p>
+ <div class="flex flex-col">
+ <div v-for="field in fields" :key="field.label" class="whitespace-pre-wrap">
+ <span class="text-foreground-1">{{ field.label }}: </span>
+ <span class="text-foreground-0">{{ field.value ?? '—' }}</span>
+ </div>
+ </div>
+ </div>
+</template>
diff --git a/resources/js/components/cards/data/attachments/SubtitleCard.vue b/resources/js/components/cards/data/attachments/SubtitleCard.vue
index 94343a08..11fe4dc2 100644
--- a/resources/js/components/cards/data/attachments/SubtitleCard.vue
+++ b/resources/js/components/cards/data/attachments/SubtitleCard.vue
@@ -22,23 +22,23 @@ const parseSubtitleFormat = (format?: string) => {
};
</script>
<template>
- <div class="data-card text-foreground-2 w-full space-y-2 rounded-lg p-3 shadow-sm">
+ <div class="data-card bg-surface-2 text-foreground-2 w-full space-y-2 rounded-lg p-3 shadow-sm">
<div class="flex items-center justify-between gap-2">
<p class="text-foreground-0 truncate">
<span class="text-foreground-2 font-normal">{{ track.track_id }}.</span>
{{ track.title || 'Untitled track' }}
</p>
- <div class="flex shrink-0 gap-1">
+ <div class="flex shrink-0 gap-1 *:text-xs">
<MediaTag v-if="track.is_default" class="bg-primary! text-foreground-i! dark:bg-white!">Default</MediaTag>
- <MediaTag v-if="track.is_forced" class="text-foreground-7! dark:text-foreground-0! bg-neutral-200! dark:bg-neutral-400!">Forced</MediaTag>
- <MediaTag v-if="track.external_path" class="text-foreground-7! dark:text-foreground-0! bg-neutral-200! dark:bg-neutral-400!">External</MediaTag>
+ <MediaTag v-if="track.is_forced" class="text-foreground-0 pointer-events-none py-0.5 text-xs">Forced</MediaTag>
+ <MediaTag v-if="track.external_path" class="text-foreground-0 pointer-events-none py-0.5 text-xs">External</MediaTag>
</div>
</div>
<div class="flex justify-between gap-2">
<div class="flex flex-wrap gap-x-1 tracking-wide uppercase">
<span>{{ track.language ?? 'und' }}</span>
- ·
+ |
<span> {{ parseSubtitleFormat(track.codec) }}</span>
</div>
<p>
diff --git a/resources/js/components/media/MetadataInfo.vue b/resources/js/components/media/MetadataInfo.vue
index f739bee0..721a8c10 100644
--- a/resources/js/components/media/MetadataInfo.vue
+++ b/resources/js/components/media/MetadataInfo.vue
@@ -1,37 +1,23 @@
<script setup lang="ts">
+import type { MediaInfoResource } from '@/contracts/mediaInfo.ts';
import type { VideoResource } from '@/contracts/media';
-import { formatFileSize, toFormattedDate } from '@/service/util';
-import { computed, ref } from 'vue';
+import { formatFileSize, toFormattedDate, toFormattedDuration } from '@/service/util';
+import { buildStreamCards, type FfprobeStream } from '@/service/media/ffprobe';
import { MediaType } from '@/types/types';
+import { computed } from 'vue';
+import StreamInfoCard from '@/components/cards/data/attachments/StreamInfoCard.vue';
import MediaTag from '@/components/labels/MediaTag.vue';
import ProiconsChevronRight from '~icons/proicons/chevron-right';
-declare type Tab = 'metadata' | 'images' | 'subtitles' | 'fonts';
-
-const props = defineProps<{ data: VideoResource }>();
+const props = defineProps<{ data: VideoResource; mediaInfo: MediaInfoResource }>();
const isAudio = computed(() => props.data.metadata?.media_type === MediaType.AUDIO);
-const tabs = computed<Tab[]>(() => {
- const tabs: Tab[] = ['metadata', 'images'];
-
- if (isAudio.value) return tabs;
-
- if (props.data.subtitles.length) tabs.push('subtitles');
- if (props.data.fonts?.length) tabs.push('fonts');
-
- return tabs;
-});
-const activeTab = ref(tabs.value.at(0) ?? 'metadata');
-
const sumBy = <T,>(arr: T[] | undefined, fn: (item: T) => number): number => (arr ?? []).reduce((acc, item) => acc + fn(item), 0);
-const videoInfo = computed(() => ({}));
-const audioInfo = computed(() => ({}));
-
const metadataItems = computed<{ label: string; items: { label: string; value: any; to?: string }[] }[]>(() => {
if (!props.data.metadata) return [];
@@ -42,10 +28,12 @@ const metadataItems = computed<{ label: string; items: { label: string; value: a
{
label: 'Metadata',
items: [
+ { label: 'UUID', value: props.data.metadata.uuid },
+ { label: 'Metadata ID', value: props.data.metadata.id },
+ { label: 'Video ID', value: props.data.id },
{ label: 'Title', value: props.data.title },
props.data.title !== props.data.name && { label: 'Name', value: props.data.name },
- { label: 'Views', value: props.data.view_count },
- props.data.duration && { label: 'Duration', value: props.data.duration },
+ props.data.duration && { label: 'Duration', value: `${toFormattedDuration(props.data.duration)} (${props.data.duration}s)` },
...(isAudio?.value
? [
{ label: 'Artist', value: props.data.artist },
@@ -58,21 +46,10 @@ const metadataItems = computed<{ label: string; items: { label: string; value: a
{ label: 'Episode', value: props.data.episode },
]),
props.data.released_at && { label: 'Released', value: props.data.released_at },
+ { label: 'Views', value: props.data.view_count },
].filter(Boolean) as { label: string; value: any; to?: string }[],
},
- !isAudio.value && {
- label: 'Video',
- items: [
- { label: 'Resolution', value: `${props.data.metadata.resolution_width}x${props.data.metadata.resolution_height}` },
- { label: 'Codec', value: props.data.metadata.codec },
- ],
- },
- {
- label: 'Audio',
- items: [{ label: 'Bitrate', value: props.data.metadata.bitrate }],
- },
-
{
label: 'Attachments',
items: [
@@ -96,10 +73,16 @@ const metadataItems = computed<{ label: string; items: { label: string; value: a
},
].filter(Boolean) as { label: string; items: { label: string; value: any; to?: string }[] }[];
});
+
+const ffprobe = computed(() => {
+ return props.mediaInfo.raw_metadata as { format: { filename: string; format_name: string; size: string }; streams: FfprobeStream[] };
+});
+
+const cards = computed(() => buildStreamCards(ffprobe.value.streams));
</script>
<template>
- <div v-if="data" class="flex flex-col gap-4 text-sm">
+ <div class="flex flex-col gap-4 text-sm">
<template v-for="(group, index) in metadataItems" :key="index">
<div class="flex flex-col gap-0.5">
<p class="">{{ group.label }}</p>
@@ -131,5 +114,11 @@ const metadataItems = computed<{ label: string; items: { label: string; value: a
</div>
</div>
</template>
+ <div class="space-y-0.5" v-if="data">
+ <p>Streams</p>
+ <div class="ms-4 grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-4">
+ <StreamInfoCard v-for="card in cards" :key="card.key" :title="card.title" :fields="card.fields" />
+ </div>
+ </div>
</div>
</template>
diff --git a/resources/js/components/media/RawInfo.vue b/resources/js/components/media/RawInfo.vue
index 2482028b..65222aa3 100644
--- a/resources/js/components/media/RawInfo.vue
+++ b/resources/js/components/media/RawInfo.vue
@@ -2,23 +2,24 @@
import type { MediaInfoResource } from '@/contracts/mediaInfo';
import type { VideoResource } from '@/contracts/media';
+import { ButtonBase } from '@/components/cedar-ui/button';
+
+import useClipboard from '@/composables/useClipboard';
+
import ProiconsChevronRight from '~icons/proicons/chevron-right';
defineProps<{ data: VideoResource; mediaInfo: MediaInfoResource }>();
+
+const clipboard = useClipboard();
</script>
<template>
<div class="flex flex-col gap-4">
- <details class="group/raw-metadata flex flex-col open:gap-2">
- <summary class="hover:text-foreground-0 flex w-fit cursor-pointer items-center gap-1.5 transition-colors">
- <ProiconsChevronRight class="-ms-1 size-3 transition-transform duration-200 group-open/raw-metadata:rotate-90" />
-
- Raw Metadata
- </summary>
-
- <pre class="scrollbar-minimal bg-surface-2 text-foreground-1 max-h-90 overflow-x-auto rounded-lg p-3 text-xs leading-relaxed whitespace-pre-wrap shadow-sm">{{
- JSON.stringify(
- {
+ <details
+ v-for="block in [
+ {
+ label: 'Metadata',
+ value: {
...data,
metadata: {
...data.metadata,
@@ -26,22 +27,41 @@ defineProps<{ data: VideoResource; mediaInfo: MediaInfoResource }>();
},
fonts: '...',
},
- null,
- 2,
- )
- }}</pre>
- </details>
-
- <details class="group/raw-info flex flex-col open:gap-2">
- <summary class="hover:text-foreground-0 flex w-fit cursor-pointer items-center gap-1.5 transition-colors">
- <ProiconsChevronRight class="-ms-1 size-3 transition-transform duration-200 group-open/raw-info:rotate-90" />
-
- Raw Media Info
+ },
+ { label: 'Media Info', value: mediaInfo.raw_metadata },
+ ]"
+ :key="block.label"
+ :open="true"
+ :class="['flex flex-col open:gap-2', `group/block`]"
+ >
+ <summary class="hover:text-foreground-0 flex w-full cursor-pointer items-center gap-1.5 transition-colors">
+ <ProiconsChevronRight :class="['-ms-1 size-3 transition-transform duration-200', `group-open/block:rotate-90`]" />
+ <p>{{ block.label }}</p>
+ <div class="relative z-20 ms-auto flex items-center">
+ <Transition
+ enter-active-class="transition ease-out duration-300"
+ enter-from-class="opacity-0 translate-x-2"
+ enter-to-class="opacity-100 translate-x-0"
+ leave-active-class="transition ease-in duration-300"
+ leave-from-class="opacity-100 translate-x-0"
+ leave-to-class="opacity-0 translate-x-2"
+ >
+ <div v-if="clipboard.copyNotification.value.has(block.label)" class="absolute -left-2 flex w-0" v-cloak>
+ <div class="border-success bg-success -ml-1.5 flex h-7 -translate-x-full items-center rounded-md border-r px-3 text-xs text-white">
+ <span>Copied!</span>
+ <div class="absolute top-1.75 -right-3 -mt-px inline-block h-full overflow-hidden">
+ <div class="bg-success size-3 origin-top-left rotate-45 transform border border-transparent"></div>
+ </div>
+ </div>
+ </div>
+ </Transition>
+ <ButtonBase class="text-foreground-2 h-fit px-0 py-0 text-xs transition-colors" @click="clipboard.copyToClipboard(block.value, block.label)">Copy</ButtonBase>
+ </div>
</summary>
-
- <pre class="scrollbar-minimal bg-surface-2 text-foreground-1 max-h-90 overflow-x-auto rounded-lg p-3 text-xs leading-relaxed whitespace-pre-wrap shadow-sm">{{
- JSON.stringify(mediaInfo.raw_metadata, null, 2)
- }}</pre>
+ <pre
+ class="scrollbar-minimal bg-surface-2 text-foreground-0 max-h-90 overflow-auto rounded-lg p-3 text-xs leading-relaxed whitespace-pre-wrap shadow-sm dark:bg-neutral-700"
+ >{{ JSON.stringify(block.value, null, 2) }}</pre
+ >
</details>
</div>
</template>
diff --git a/resources/js/components/modals/MediaInfoModal.vue b/resources/js/components/modals/MediaInfoModal.vue
index 4421ceaf..fb199c56 100644
--- a/resources/js/components/modals/MediaInfoModal.vue
+++ b/resources/js/components/modals/MediaInfoModal.vue
@@ -9,23 +9,22 @@ import { useModalStore } from '@/stores/ModalStore';
import { computed, ref } from 'vue';
import { storeToRefs } from 'pinia';
import { ButtonBase } from '@/components/cedar-ui/button/index.ts';
-import { MediaType } from '@/types/types';
import { BaseModal } from '@/components/cedar-ui/modal';
import { useQuery } from '@tanstack/vue-query';
import { useAuth } from '@/composables/auth/useAuth';
import { cn } from '@aminnausin/cedar-ui';
+import MediaInfoSkeleton from '@/components/skeleton/MediaInfoSkeleton.vue';
import ModalFormFooter from '@/components/forms/ModalFormFooter.vue';
import EditItemHeader from '@/components/headers/EditItemHeader.vue';
import SubtitlesInfo from '@/components/media/SubtitlesInfo.vue';
import MetadataInfo from '@/components/media/MetadataInfo.vue';
import FontsInfo from '@/components/media/FontsInfo.vue';
import ImageInfo from '@/components/media/ImageInfo.vue';
-import RawInfo from '@/components/media/RawInfo.vue';
import ProIconsPhoto from '@/components/icons/ProIconsPhoto.vue';
-declare type Tab = 'metadata' | 'images' | 'subtitles' | 'fonts' | 'raw';
+declare type MediaInfoTab = 'metadata' | 'images' | 'subtitles' | 'fonts';
const modal = useModalStore();
@@ -33,13 +32,10 @@ const { title, mediaResource: data } = modal.getProps<MediaMetadataEditorProps>(
const { stateDirectory } = storeToRefs(useContentStore());
const { isAuthenticated } = useAuth();
-const isAudio = computed(() => data.metadata?.media_type === MediaType.AUDIO);
const mediaId = computed(() => data.id);
-const tabs = computed<Tab[]>(() => {
- const tabs: Tab[] = ['metadata', 'images', 'raw'];
-
- if (isAudio.value) return tabs;
+const tabs = computed<MediaInfoTab[]>(() => {
+ const tabs: MediaInfoTab[] = ['metadata', 'images'];
if (data.subtitles.length) tabs.push('subtitles');
if (data.fonts?.length) tabs.push('fonts');
@@ -47,16 +43,15 @@ const tabs = computed<Tab[]>(() => {
return tabs;
});
-const activeTab = ref<Tab>(tabs.value.at(0) ?? 'metadata');
-const panels: Record<Tab, Component> = {
+const activeTab = ref<MediaInfoTab>(tabs.value.at(0) ?? 'metadata');
+const panels: Record<MediaInfoTab, Component> = {
metadata: MetadataInfo,
images: ImageInfo,
subtitles: SubtitlesInfo,
fonts: FontsInfo,
- raw: RawInfo,
};
-const { data: mediaInfo } = useQuery({
+const { data: mediaInfo, isLoading } = useQuery({
queryKey: ['video-info', mediaId.value],
queryFn: () => getMediaDetails(mediaId.value),
enabled: computed(() => modal.isOpen),
@@ -72,21 +67,22 @@ const { data: mediaInfo } = useQuery({
<div class="contents text-sm">
<div class="bg-surface-3/50 dark:bg-surface-3 mr-auto flex w-fit gap-0.5 rounded-lg p-0.5">
<ButtonBase
- v-for="tab in tabs"
- :key="tab"
+ v-for="MediaInfoTab in tabs"
+ :key="MediaInfoTab"
:class="
cn('h-7 rounded-md px-3 py-1 capitalize transition-colors', {
- 'bg-surface-1 dark:bg-surface-4 text-primary-active dark:text-primary-muted shadow-sm': activeTab === tab,
- 'text-foreground-2 hover:text-foreground-0': activeTab !== tab,
+ 'bg-surface-1 dark:bg-surface-4 text-primary-active dark:text-primary-muted shadow-sm': activeTab === MediaInfoTab,
+ 'text-foreground-2 hover:text-foreground-0': activeTab !== MediaInfoTab,
})
"
- @click="activeTab = tab"
+ @click="activeTab = MediaInfoTab"
>
- {{ tab }}
+ {{ MediaInfoTab }}
</ButtonBase>
</div>
- <component :is="panels[activeTab]" :data="data" :media-info="mediaInfo" />
+ <MediaInfoSkeleton v-if="isLoading" />
+ <component v-else :is="panels[activeTab]" :data="data" :media-info="mediaInfo" />
<ModalFormFooter class="*:h-9" v-if="isAuthenticated">
<ButtonBase
diff --git a/resources/js/components/skeleton/MediaInfoSkeleton.vue b/resources/js/components/skeleton/MediaInfoSkeleton.vue
new file mode 100644
index 00000000..7fe37d04
--- /dev/null
+++ b/resources/js/components/skeleton/MediaInfoSkeleton.vue
@@ -0,0 +1,21 @@
+<script setup lang="ts">
+const rowGroups = [
+ { header: 'w-20', rows: [3, 4, 3.5, 5, 2, 2.5] },
+ { header: 'w-24', rows: [2, 4, 2] },
+ { header: 'w-24', rows: [3, 4, 3.5] },
+];
+</script>
+
+<template>
+ <div class="pointer-events-none flex animate-pulse flex-col gap-4">
+ <div v-for="(group, gi) in rowGroups" :key="gi" class="flex flex-col gap-2">
+ <div :class="['bg-foreground-1/20 h-4 rounded', group.header]"></div>
+ <div class="ms-4 flex flex-col gap-1.5">
+ <div v-for="(w, ri) in group.rows" :key="ri" class="flex items-center gap-2">
+ <div class="bg-foreground-2/10 h-3 w-16 rounded-sm"></div>
+ <div class="bg-foreground-2/10 h-3 rounded-sm" :style="{ width: `${w}rem` }"></div>
+ </div>
+ </div>
+ </div>
+ </div>
+</template>
diff --git a/resources/js/service/media/ffprobe.ts b/resources/js/service/media/ffprobe.ts
new file mode 100644
index 00000000..56f4bad0
--- /dev/null
+++ b/resources/js/service/media/ffprobe.ts
@@ -0,0 +1,136 @@
+export interface FfprobeStream {
+ index: number;
+ codec_type: 'video' | 'audio' | 'subtitle' | 'attachment';
+ codec_name?: string;
+ profile?: string;
+ level?: number;
+ width?: number;
+ height?: number;
+ sample_aspect_ratio?: string;
+ display_aspect_ratio?: string;
+ field_order?: string;
+ r_frame_rate?: string;
+ avg_frame_rate?: string;
+ bit_rate?: string;
+ bits_per_raw_sample?: string;
+ pix_fmt?: string;
+ color_space?: string;
+ color_transfer?: string;
+ color_primaries?: string;
+ refs?: number;
+ nal_length_size?: string;
+ is_avc?: string;
+ channels?: number;
+ channel_layout?: string;
+ sample_rate?: string;
+ disposition?: Record<string, number>;
+ tags?: Record<string, string>;
+}
+
+export interface StreamField {
+ label: string;
+ value?: string | number;
+}
+
+export interface StreamCard {
+ key: string;
+ type: 'video' | 'audio' | 'subtitle';
+ title: string;
+ fields: StreamField[];
+}
+
+const parseFraction = (fraction?: string): number => {
+ if (!fraction) return 0;
+ const [n, d] = fraction.split('/').map(Number);
+ return d ? n / d : n;
+};
+
+const formatBitrate = (bps?: string | number): string => {
+ const n = Number(bps);
+ return n ? `${Math.round(n / 1000)} kbps` : '—';
+};
+
+const formatFlag = (flag?: string | number): string => (flag && flag !== '0' ? 'Yes' : 'No');
+
+const videoRange = (stream: FfprobeStream): { range: string; type?: string } => {
+ if (stream.color_transfer === 'smpte2084') return { range: 'HDR', type: 'HDR10' };
+ if (stream.color_transfer === 'arib-std-b67') return { range: 'HDR', type: 'HLG' };
+ return { range: 'SDR' };
+};
+
+function buildVideoCard(s: FfprobeStream): StreamCard {
+ const { range, type } = videoRange(s);
+ const fps = parseFraction(s.avg_frame_rate ?? s.r_frame_rate);
+
+ return {
+ key: `stream-${s.index}`,
+ type: 'video',
+ title: `${s.index}. Video`,
+ fields: [
+ { label: 'Title', value: s.tags?.title },
+ { label: 'Codec', value: s.codec_name?.toUpperCase() },
+ { label: 'Profile', value: s.profile },
+ { label: 'Resolution', value: `${s.width}x${s.height}` },
+ { label: 'Aspect ratio', value: s.display_aspect_ratio },
+ { label: 'Framerate', value: fps ? Math.round(fps).toString() : '—' },
+ { label: 'Bitrate', value: formatBitrate(s.bit_rate ?? s.tags?.BPS) },
+ { label: 'Bit depth', value: s.bits_per_raw_sample ? `${s.bits_per_raw_sample} bit` : '—' },
+ { label: 'Video range', value: range },
+ ...(type ? [{ label: 'Video range type', value: type }] : []),
+ { label: 'Colour space', value: s.color_space },
+ { label: 'Pixel format', value: s.pix_fmt },
+ ],
+ };
+}
+
+function buildAudioCard(s: FfprobeStream): StreamCard {
+ return {
+ key: `stream-${s.index}`,
+ type: 'audio',
+ title: `${s.index}. Audio`,
+ fields: [
+ { label: 'Title', value: s.tags?.title },
+ { label: 'Language', value: s.tags?.language ?? 'und' },
+ { label: 'Codec', value: s.codec_name?.toUpperCase() },
+ { label: 'Layout', value: s.channel_layout },
+ { label: 'Channels', value: s.channels },
+ { label: 'Bitrate', value: formatBitrate(s.bit_rate ?? s.tags?.BPS) },
+ { label: 'Sample rate', value: s.sample_rate ? `${s.sample_rate} Hz` : '—' },
+ { label: 'Default', value: formatFlag(s.disposition?.default) },
+ { label: 'Forced', value: formatFlag(s.disposition?.forced) },
+ ],
+ };
+}
+
+function buildSubtitleCard(s: FfprobeStream): StreamCard {
+ return {
+ key: `stream-${s.index}`,
+ type: 'subtitle',
+ title: `${s.index} Subtitle`,
+ fields: [
+ { label: 'Title', value: s.tags?.title },
+ { label: 'Language', value: s.tags?.language ?? 'und' },
+ { label: 'Codec', value: s.codec_name?.toUpperCase() },
+ { label: 'Default', value: formatFlag(s.disposition?.default) },
+ { label: 'Forced', value: formatFlag(s.disposition?.forced) },
+ ],
+ };
+}
+
+export function buildStreamCards(streams: FfprobeStream[], types: FfprobeStream['codec_type'][] = ['video', 'audio']): StreamCard[] {
+ return streams
+ .filter((s) => types.includes(s.codec_type))
+ .map((s) => {
+ switch (s.codec_type) {
+ case 'video':
+ return buildVideoCard(s);
+ case 'audio':
+ return buildAudioCard(s);
+ case 'subtitle':
+ return buildSubtitleCard(s);
+ default:
+ return undefined;
+ }
+ })
+ .filter((s): s is StreamCard => s !== undefined);
+}