Waveform: decode peaks in-renderer via Web Audio (no external ffmpeg needed)

The packaged app doesn't bundle ffmpeg, so on Macs without a system ffmpeg the
waveform stayed blank. Compute peaks by reading the file bytes (new file:read
IPC) and decoding with Web Audio's decodeAudioData in a low-rate AudioContext;
ffmpeg in main remains only as a fallback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
lucianoandClaude Opus 4.8 committed 2026-06-22 18:03:29 +02:00
1 parent c98ebda03f
commit 0c2f2b8190
3 files changed
+47 -6

No files matched your search

+7
View File
@@ -134,6 +134,13 @@ function transcodeToMp4(input, output, opts) {
});
}
// Read raw file bytes for the renderer (used to decode waveforms via Web Audio,
// which needs no external ffmpeg). Returns null if unreadable.
ipcMain.handle('file:read', async (_e, filePath) => {
try { return await fs.promises.readFile(filePath); }
catch (e) { return null; }
});
// Decode a media file to mono 8 kHz PCM via ffmpeg and reduce it to `buckets`
// peak amplitudes (0..1) for drawing a waveform. Returns null on failure.
const peaksCache = new Map();