Reputation: 829
I want to add two variable in addFilter() function. But the problem is that this method allows only one parameter to get. How to extend it?
FMpeg::fromDisk('public')
->open('/uploads/videos/' .$video->file_name)
->addFilter(function($filters) {
$filters->clip(FFMpeg\Coordinate\TimeCode::fromSeconds($start), FFMpeg\Coordinate\TimeCode::fromSeconds($duration));
})
->export()
->toDisk('public')
definition of code: I can't change this
public function addFilter(FilterInterface $filter)
{
$this->filters->add($filter);
return $this;
}
Upvotes: 0
Views: 287
Reputation: 11711
You may want to use use
with the function to pass those variables to the Clousure
FMpeg::fromDisk('public')
->open('/uploads/videos/' .$video->file_name)
->addFilter(function($filters) use($start, $duration) {
$filters->clip(FFMpeg\Coordinate\TimeCode::fromSeconds($start), FFMpeg\Coordinate\TimeCode::fromSeconds($duration));
})
->export()
->toDisk('public')
Upvotes: 2