@gigamusic/audio
v4.3.0
Published
Server-only audio utilities: ffmpeg preview generation, WAV/MP3 tagging. Never writes album_artist / TPE2.
Readme
@gigamusic/audio
Server-only audio utilities for the gigamusic platform: ffmpeg-driven preview generation and WAV/MP3 metadata tagging.
The albumArtist / ID3 TPE2 frame is never written. The invariant is enforced both at the type level (no albumArtist on AudioTags) and at runtime (any internal frame map strips TPE2).
import { generatePreview, tagMp3, tagWav, prepareFfmpegScriptPath } from "@gigamusic/audio";Staging the ffmpeg binary
ffmpeg-driven routes need the binary at a stable, non-symlinked project path (./bin/ffmpeg). Consumers run the bundled copy script from a thin ESM shim during their build — this package is ESM-only, so resolve the path via import, not require:
// scripts/prepare-ffmpeg.mjs
import { prepareFfmpegScriptPath } from "@gigamusic/audio";
await import(prepareFfmpegScriptPath);// package.json — use `build`, not just `vercel-build`, so it runs whichever
// script the deploy/monorepo build actually invokes.
"build": "node scripts/prepare-ffmpeg.mjs && next build"Also gitignore the bin/ directory and never commit the staged binary — it is platform-specific (a dev-machine macOS binary will fail on a Linux deploy with cannot execute binary file); regenerate it per build instead.
ffmpegBinary() is exported for consumers that spawn ffmpeg directly: it prefers the staged ./bin/ffmpeg and falls back to ffmpeg-static.
