Detect FFmpeg installation and Version Detect FFmpeg installation and Version php php

Detect FFmpeg installation and Version


Try:

$ffmpeg = trim(shell_exec('which ffmpeg')); // or better yet:$ffmpeg = trim(shell_exec('type -P ffmpeg'));

If it comes back empty ffmpeg is not available, otherwise it will hold the absolute path to the executable, which you may use in the actual ffmpeg call:

if (empty($ffmpeg)){    die('ffmpeg not available');}shell_exec($ffmpeg . ' -i ...');


The third parameter to the exec() function is the return value of the executed program. Use it like this:

exec($cmd, $output, $returnvalue);if ($returnvalue == 127) {    # not available}else {    #available}

This works on my Ubuntu box.


You answered your own question, you can run the command and if it comes back negative you know it is not installed, or you can check the default paths the user has set for possible ffmpeg binaries.