0

I want to get the duration of a video file in php

I have checked online and I saw posts talking discussing getid3, I downloaded it and include the fil in my php code but it was telling me it couldn't read the file. I also saw some posts discussing ffmpeg in php, but I dont understand how it works. I will be happy if I can do it with pure php. But if not, please explain in details how I can get this done.

$filename = $_FILES["adspics"]["name"];
$getID3 = new getID3;
$file = $getID3->analyze($filename);
echo ($file['playtime_string']);

I expected it do display the duration of the video

atomty
  • 187
  • 2
  • 16
  • Possible duplicate of [php-ffmpeg get video duration](https://stackoverflow.com/questions/43922925/php-ffmpeg-get-video-duration) – zod Jun 17 '19 at 21:47
  • 1
    If you think of capturing the duration of the video with javascript before uploading the video and assigning it to a hidden form input, I may have an answer. If this method works, it's easier than using an additional library, and using less resources of server. – Mahir Özdin Jun 17 '19 at 22:01
  • Thanks, I just did this... Superb – atomty Jun 17 '19 at 22:35

0 Answers0