
Why ffmpeg astats Crashes Node.js child_process (And the One-Line Fix)
If you're using ffmpeg from Node.js via execFile or execSync , there's a subtle way it can crash your app: stdout/stderr buffer overflow . I ran into this while building an audio analysis pipeline that scores video segments by energy, silence, and dynamic range. Everything worked in development on short clips. In production, on a 45-minute video? Instant crash. The Setup We needed RMS volume and peak levels for audio segments. The natural ffmpeg approach is astats : import { execFile } from " child_process " ; import { promisify } from " util " ; const execFileAsync = promisify ( execFile ); async function analyzeRms ( audioPath : string , start : number , duration : number ) { const { stderr , stdout } = await execFileAsync ( " ffmpeg " , [ " -ss " , String ( start ), " -t " , String ( duration ), " -i " , audioPath , " -af " , " astats=metadata=1:reset=1,ametadata=print:file=- " , " -f " , " null " , " - " , ], { timeout : 30000 } ); const output = stderr + stdout ; const rmsMatch =
Continue reading on Dev.to Webdev
Opens in a new tab


