Skip to content

node-av / ffmpeg / isFfmpegAvailable

Function: isFfmpegAvailable()

isFfmpegAvailable(): boolean

Defined in: src/ffmpeg/index.ts:101

Check if the FFmpeg binary is available and executable.

Verifies that the FFmpeg binary exists at the expected location. This is useful for checking if the installation was successful before attempting to use the binary.

Returns

boolean

true if FFmpeg binary exists, false otherwise

Examples

typescript
import { isFfmpegAvailable, ffmpegPath } from 'node-av/ffmpeg';

if (isFfmpegAvailable()) {
  console.log('FFmpeg is ready to use');
  // Safe to use ffmpegPath() and execute FFmpeg commands
} else {
  console.log('FFmpeg binary not found');
  console.log('Expected location:', ffmpegPath());
  console.log('Try running: npm install node-av');
}
typescript
import { isFfmpegAvailable, ffmpegPath } from 'node-av/ffmpeg';
import { execFile } from 'node:child_process';

async function getFFmpegVersion(): Promise<string | null> {
  if (!isFfmpegAvailable()) {
    return null;
  }

  try {
    const { stdout } = await execFile(ffmpegPath(), ['-version']);
    return stdout;
  } catch (error) {
    console.error('Failed to execute FFmpeg:', error);
    return null;
  }
}