Skip to content

feat(studio): server-side waveform generation with caching#497

Merged
miguel-heygen merged 1 commit intoheygen-com:mainfrom
alexcraviotto:feat/no-ref/server-side-waveform-generation
Apr 25, 2026
Merged

feat(studio): server-side waveform generation with caching#497
miguel-heygen merged 1 commit intoheygen-com:mainfrom
alexcraviotto:feat/no-ref/server-side-waveform-generation

Conversation

@alexcraviotto
Copy link
Copy Markdown
Contributor

What

Add server-side waveform generation for audio assets in the Studio, backed by a new /api/projects/:id/waveform/* endpoint and an on-disk cache.

Why

Waveform peaks were previously decoded entirely in the browser using the Web Audio API. For small files or projects with few audio tracks this is barely noticeable, but the approach has two compounding problems:

Memory pressure under real-world usage. Decoding audio in the browser allocates large ArrayBuffers and AudioBuffers on the main thread. For longer audio files this gets expensive, and the situation worsens when the user interacts with the timeline while decoding is still in progress, for example, dragging an audio clip to a new position. Repeating this a few times caused: (status code 5 / ERR_OUT_OF_MEMORY).

image

No persistence between sessions. Because decoding happened at render time with no caching, every time the project was reopened every waveform had to be fully recomputed from scratch, repeating the same expensive work indefinitely.
Moving decoding to the server with FFmpeg and persisting the result to disk solves both: the browser receives a small JSON array, and subsequent loads (including re-opens) are instant from cache.

How

Moved all waveform processing to the server so the browser no longer has to do any heavy lifting. The server decodes the audio, computes the peaks, and sends back a small JSON array that the AudioWaveform component renders directly.

Added a cache layer similar to the existing preview system. Once an audio file is processed, the result is saved to disk so reopening the project or reloading the page does not trigger any recomputation.

Test plan

How was this tested?

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)

@miguel-heygen miguel-heygen merged commit a00161d into heygen-com:main Apr 25, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants