mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
24 lines
600 B
TypeScript
24 lines
600 B
TypeScript
export interface FFprobeFlags {
|
|
'v'?: string;
|
|
'select_streams'?: string;
|
|
'show_entries'?: string;
|
|
'of'?: string;
|
|
[key: string]: string | undefined;
|
|
}
|
|
|
|
export function ffprobe(path: URL | string, flags: FFprobeFlags): ReadableStream<Uint8Array> {
|
|
const args = [];
|
|
|
|
for (const [key, value] of Object.entries(flags)) {
|
|
if (typeof value === 'string') {
|
|
args.push(`-${key}`, value);
|
|
}
|
|
}
|
|
|
|
args.push(path instanceof URL ? path.href : path);
|
|
|
|
const command = new Deno.Command('ffprobe', { args, stdout: 'piped' });
|
|
const child = command.spawn();
|
|
|
|
return child.stdout;
|
|
}
|