Are you calculating it on the fly; would you be better to calculate and store the video duration with the database record (if that exists)? If you calculate and store the duration with each video then a Collection sum will work for the total duration.
Get total (video durations) with GetID3
Dear all,
I am building a Laravel app in which I upload videos.
To recover the duration of each video, I use the following package which is very good: https://github.com/JamesHeinrich/getID3/
Where I need help is to get the total duration of all the videos and I have no idea how to handle this.
Here is an image that illustrates my research:
https://i.stack.imgur.com/XzSKP.png
public function getVideoDuration($Videofile) { $getID3 = new \getID3(); $pathVideo = 'storage/chapitres-videos/' . Auth::user()->id . '/' . $Videofile; $fileAnalyze = $getID3->analyze($pathVideo); $playtime = $fileAnalyze['playtime_string'];
return $playtime;
}
$Videofile = $this->videoManager->videoStorage($request->file('video')); $lecture->video = $Videofile;
Thank you all and have a nice day!
Please or to participate in this conversation.