Error with Laravel and FFMpeg in queue job

683 views Asked by At

I'm using Laravel with the protonemedia/laravel-ffmpeg package https://github.com/protonemedia/laravel-ffmpeg I create a Job to handle video conversion and concatenation and this error appears:

TypeError: Argument 1 passed to App\Jobs\VideoConversion::App\Jobs{closure}() must be an instance of FFMpeg\Filters\Video\VideoFilters, instance of FFMpeg\Filters\AdvancedMedia\ComplexFilters given in /Users/fab/Sites/add-intro/app/Jobs/VideoConversion.php:43

Here is the code of the Job:

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

use App\Models\Video;

use Storage, Str, ProtoneMedia\LaravelFFMpeg\Support\FFMpeg;

use FFMpeg\Filters\Video\VideoFilters;

class VideoConversion implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $video;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(Video $video)
    {
        $this->video = $video;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $filename = Str::uuid().'.mp4';
        FFMpeg::fromDisk('public')
        ->open(['intro.mp4', $this->video->path])
        ->addFilter(function (VideoFilters $filters) {
            $filters->resize(new \FFMpeg\Coordinate\Dimension(640, 480));
        })
        ->export()
        ->toDisk('public')
        ->inFormat(new \FFMpeg\Format\Video\X264)
        ->concatWithTranscoding($hasVideo = true, $hasAudio = true)
        ->save($filename);
    }

    public function failed(Throwable $exception)
    {
        FFMpeg::cleanupTemporaryFiles();
        dd($exception);
    }
}

What I'm doing wrong ? Thanks for help

0

There are 0 answers