我想在addFilter()函数中添加两个变量。但问题是这个方法只允许一个参数。如何延长?
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')
代码定义:我无法改变这个
public function addFilter(FilterInterface $filter)
{
$this->filters->add($filter);
return $this;
}
答案 0 :(得分:2)
您可能希望使用use
函数将这些变量传递给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')