protonemedia / laravel-ffmpeg

This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.
https://protone.media/en/blog/how-to-use-ffmpeg-in-your-laravel-projects
MIT License
1.66k stars 194 forks source link

Package Passing wrong class to PHPFFMpeg->addFilter() #388

Closed Insax closed 2 years ago

Insax commented 2 years ago

So basically I'm trying to convert a video with a few filters


use FFMpeg\Coordinate\Dimension;
use FFMpeg\Coordinate\TimeCode;
use FFMpeg\Filters\Video\VideoFilters;

FFMpeg::fromDisk($this->videoList->input_disk)
            ->open($this->videoList->filename)
            ->addFilter(function (VideoFilters $filters) {
                $filters->resize(new Dimension($this->width, $this->height));
                $filters->clip(TimeCode::fromSeconds($this->start), TimeCode::fromSeconds($this->end - $this->start));
            })
            ->export()
            ->onProgress(function ($percentage, $remaining, $rate) {
                $this->videoList->video->update([
                    'convert_progress' => $percentage,
                    'convert_remaining' => $remaining,
                    'convert_rate' => $rate
                ]);
            })
            ->inFormat($this->format)
            ->toDisk($this->videoList->result_disk)
            ->save($this->videoList->guid.'.mp4');

Which causes the class to abort with the following exception: Argument #1 ($filters) must be of type FFMpeg\Filters\Video\VideoFilters, FFMpeg\Filters\AdvancedMedia\ComplexFilters given {"exception":"[object] (TypeError(code: 0): App\\Jobs\\ConvertVideoJob::App\\Jobs\\{closure}(): Argument #1 ($filters) must be of type FFMpeg\\Filters\\Video\\VideoFilters, FFMpeg\\Filters\\AdvancedMedia\\ComplexFilters given at /project/path/app/Jobs/ConvertVideoJob.php:50)

whilst line 50 is exactly $filters->resize(new Dimension($this->width, $this->height)); Also calling the helper method ->resize() itself does not fix the problem, at it seems to call the addComplexFilter method which should not be called in the first place

Insax commented 2 years ago

Fixed, it seems it was my own stupidity

-> The path i provided to open the file was wrong, thus it seems very weird things happend afterwards