I also wanted to do this recently. I have done a lot of research on this and there is no native way in php. One of the suggestions of ffmpeg-php , but it doesn't seem to work for me. Another method is to use the ffmpeg command line:
exec("ffmpeg -i \"{$videofile}\" 2>&1"); $search='/Duration: (.*?),/'; $duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE, 3);
source share