$videofile = "fichier.flv";
ob_start();
passthru("ffmpeg -i "{$videofile}" 2>&1");
$duration = ob_get_contents();
ob_end_clean();
$search='/Duration: (.*?),/';
$duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE, 3);
echo $matches[1][0];
Pour récupérer la durée, en seconde, on peut utiliser cette fonction :
echo hms2sec($matches[1][0]);
function hms2sec ($hms) {
list($h, $m, $s) = explode (":", $hms);
$seconds = 0;
$seconds += (intval($h) * 3600);
$seconds += (intval($m) * 60);
$seconds += (intval($s));
return $seconds;
}