1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
public function getVideoDuration($videoUrl) { try { set_time_limit(0); $command = sprintf('ffprobe -v quiet -of csv=p=0 -select_streams v:0 -show_entries stream=duration %s 2>&1', escapeshellarg($videoUrl)); exec($command, $output, $returnVar); if ($returnVar !== 0) { throw new Exception("Failed to execute FFmpeg command: " . implode("\n", $output)); } return $output[0]; } catch (Exception $exception) { return 0; } }
|