Is there a way to read the metadata of a video file to get the duration of the vid?
I know I can do it in JS when the video is downloaded, but all I want is the play duration.
Edit: I believe I can used FFmpeg but it seems a big package to load just for what I need.
Use GetID3. It has features that allow you to look for the length of the video. I’m currently at work so I can’t give any demo samples. Unless someone can provide something before I do.
Thanks, @spaceshiptrooper. I’ll take that for a test drive…
Edit: Looking good…
$getID3 = new getID3;
$filename = 'LiverpoolJudies.mp4';
$ThisFileInfo = $getID3->analyze($filename);
Update: I found it took a noticeable time to get the play time for just 5 vids, delaying the page load, so I decided to implement it using AJAX. Works a treat.
Sounds like something that would be easily cacheable though. Do you have something like APC, Redis or Memcache installed?
Yes, it does get cached. In truth, I could have manually entered the play times, but it was a useful learning exercise.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.