Thursday, July 6, 2017

How to get duration a video - laravel

Asked by: S.M_Emamian


I want to get the duration of my videos when I upload them. To do this, I upload my videos like this:

$video = Carbon::now()->timestamp . '_' .
            $request->file('video')->getClientOriginalName();


        $request->file('video')->move(
            $this->getCorrectPathOnServerAndLocal('/assets/videos/videos'), $video
        );

My movie is uploaded well. now I want to get the duration of this video. I'm using PHP-FFMpeg:

composer require php-ffmpeg/php-ffmpeg

$ffprobe = FFProbe::create(); //error
        dd("test");
        $duration = $ffprobe
            ->format($this->getCorrectPathOnServerAndLocal('/assets/videos/videos').$video) // extracts file informations
            ->get('duration');

but I got this error:

  (2/2) ExecutableNotFoundException

Unable to load FFProbe
in FFProbeDriver.php (line 50)
at FFProbeDriver::create(array(), null)in FFProbe.php (line 207)


Source

No comments:

Post a Comment

Adbox