0

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;
    }
5
  • Just add it... explain what exactly you want to add and what do you want to do with them (with the variables) Commented Nov 27, 2017 at 22:21
  • What are you trying to do to add an additional parameter? Commented Nov 27, 2017 at 22:22
  • @lewis4u when I try to add my app says that function requires 1 parameter 3 given Commented Nov 27, 2017 at 22:32
  • But which function has 3 parameters...here in your code there is a function with 1 and 2 parameters, but none with 3 Commented Nov 27, 2017 at 22:33
  • I have function addFilter() with 1 parameter. I want to pass to this function $start and $duration, because that variables aren't visible in this function Commented Nov 27, 2017 at 22:36

1 Answer 1

2

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')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.