I'm trying to set up a video platform for myself and for this I would like to make a timelapse from frames I'm taking from the uploaded video. This worked as long as I only took one frame from the video. The moment I tried to take more than one I got the error message:
Call to undefined method FFMpeg\Media\Frame::frame()
The library I'm using is this one: laravel-ffmpeg
In my video controller (@store) I'm using a for loop to open the already saved video over and over until I have enough frames to make the timelapse out of it.
for ($i = 1; $i < $durationInSeconds; $i+=5){
$media = FFMpeg::fromDisk('videos')
->open($videoNameToStore)
->getFrameFromSeconds($i)
->export()
->toDisk('thumbnails')
->save($i.$thumbnailNameToStore);
}
The thing is now that it only works in the first iteration. On the second it stops with the above mentioned error. Any ideas what I'm doing wrong?
Stack Trace:
ProtoneMedia\LaravelFFMpeg\Drivers\PHPFFMpeg::frame
vendor/pbmedia/laravel-ffmpeg/src/Drivers/PHPFFMpeg.php:113
$this->mediaCollection = $mediaCollection;
$localPaths = $mediaCollection->getLocalPaths();
if (count($localPaths) === 1 && !$this->forceAdvanced) {
$this->media = $this->ffmpeg->open(Arr::first($localPaths));
} else {
$this->media = $this->ffmpeg->openAdvanced($localPaths);
}
return $this;
}
public function frame(TimeCode $timecode)
{
$this->media = $this->media->frame($timecode); //-> error happens here
return $this;
}
public function concatWithoutTranscoding()
{
$localPaths = $this->mediaCollection->getLocalPaths();
$this->media = $this->ffmpeg->open(Arr::first($localPaths))
->concat($localPaths);
return $this;
}