π¦ ClawHub
ffmpeg-static
by @fantox
FFmpeg operations via the ffmpeg-static npm package (bundled binary) with automatic fallback to a native system FFmpeg installation. Use for: video/audio tra...
π Tips & Best Practices
1. Always resolve the binary once at startup
CallresolveFfmpeg() once and cache the result β don't call require('ffmpeg-static') inline in hot paths.2. Prefer -c copy when no re-encoding is needed
Stream copy (-c copy) is instantaneous and lossless. Only decode/encode when you actually need to change the codec or apply filters.3. Use -ss before -i for fast seeking
-ss 00:01:00 -i input.mp4 (before -i) uses keyframe seeking (fast). -i input.mp4 -ss 00:01:00 (after -i) decodes from the start (accurate but slow for large files).4. Always pass -y in non-interactive scripts
-y overwrites output without prompting. Without it, FFmpeg hangs waiting for stdin in CI or background processes.5. Validate inputs before building command arrays
Never interpolate user-supplied strings directly into FFmpeg args. Always validate paths exist and are the expected media type using ffprobe first.6. For hardware encoding, require system FFmpeg
Checkffmpeg -hwaccels at startup and gate hardware-accelerated paths on the system binary being active.7. Set -loglevel error in production
Reduces stderr noise. Re-enable verbose logging (-loglevel verbose) when debugging a failed transcode.TERMINAL
clawhub install ffmpeg-static