2026-09-22 10:31:30 -04:00
|
|
|
import { invoke, Channel } from '@tauri-apps/api/core';
|
2026-09-21 11:10:20 -04:00
|
|
|
|
2026-09-21 10:57:43 -04:00
|
|
|
export interface ThumbnailSpritesheet {
|
|
|
|
|
filePath: string;
|
|
|
|
|
startIndex: number;
|
|
|
|
|
count: number;
|
|
|
|
|
thumbWidth: number;
|
|
|
|
|
thumbHeight: number;
|
|
|
|
|
columns: number;
|
|
|
|
|
intervalSeconds: number;
|
|
|
|
|
}
|
2026-09-21 11:10:20 -04:00
|
|
|
|
2026-09-22 10:31:30 -04:00
|
|
|
export interface WaveformTiers {
|
|
|
|
|
/** ~2,000 peaks — overview for full-duration view */
|
|
|
|
|
tier0: number[];
|
|
|
|
|
/** ~10,000 peaks — moderate zoom */
|
|
|
|
|
tier1: number[];
|
|
|
|
|
/** All extracted peaks — deep zoom */
|
|
|
|
|
tier2: number[];
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-21 11:10:20 -04:00
|
|
|
export async function extractKeyframes(filePath: string): Promise<number[]> {
|
|
|
|
|
return invoke<number[]>('extract_keyframes', { filePath });
|
|
|
|
|
}
|
2026-09-21 11:12:36 -04:00
|
|
|
|
2026-09-22 10:31:30 -04:00
|
|
|
export async function extractWaveformTiers(
|
2026-09-21 11:12:36 -04:00
|
|
|
filePath: string,
|
2026-09-22 10:31:30 -04:00
|
|
|
duration: number,
|
|
|
|
|
onProgress?: (pct: number) => void
|
|
|
|
|
): Promise<WaveformTiers> {
|
|
|
|
|
const channel = new Channel<number>();
|
|
|
|
|
if (onProgress) {
|
|
|
|
|
channel.onmessage = onProgress;
|
|
|
|
|
}
|
|
|
|
|
return invoke<WaveformTiers>('extract_waveform_tiers', {
|
|
|
|
|
filePath,
|
|
|
|
|
duration,
|
|
|
|
|
onProgress: channel,
|
|
|
|
|
});
|
2026-09-21 11:12:36 -04:00
|
|
|
}
|
2026-09-21 11:16:10 -04:00
|
|
|
|
|
|
|
|
export async function extractThumbnails(
|
|
|
|
|
filePath: string,
|
2026-09-22 14:43:24 -04:00
|
|
|
duration: number,
|
|
|
|
|
outputDir?: string
|
2026-09-21 11:16:10 -04:00
|
|
|
): Promise<ThumbnailSpritesheet[]> {
|
|
|
|
|
return invoke<ThumbnailSpritesheet[]>('extract_thumbnails', {
|
|
|
|
|
filePath,
|
|
|
|
|
duration,
|
2026-09-22 14:43:24 -04:00
|
|
|
outputDir: outputDir ?? null,
|
2026-09-21 11:16:10 -04:00
|
|
|
});
|
|
|
|
|
}
|
2026-09-21 11:18:14 -04:00
|
|
|
|
|
|
|
|
export async function cleanupThumbnails(paths: string[]): Promise<void> {
|
|
|
|
|
return invoke<void>('cleanup_thumbnails', { paths });
|
|
|
|
|
}
|
2026-09-22 10:31:30 -04:00
|
|
|
|
|
|
|
|
export async function checkEmbeddedSubtitles(
|
|
|
|
|
filePath: string
|
|
|
|
|
): Promise<string | null> {
|
|
|
|
|
return invoke<string | null>('check_embedded_subtitles', { filePath });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function listSystemFonts(): Promise<string[]> {
|
|
|
|
|
return invoke<string[]>('list_system_fonts');
|
|
|
|
|
}
|