Laravel Media Library: Custom Manipulation/Conversion?

16 Views Asked by At

Context: What's trying to be achieved is, when a video is uploaded and added to a collection I want to have a conversion that will generate a timeline preview of the video (many frames stick together like the ones you see on a video editor timeline).

Now, I do have the code capable of generating said timeline preview. The thing is I don't want to have another media record on another collection. The ideal scenario would have it as a conversion. I know Media Library doesn't support this manipulation out of the box.

My question is how can I make it accessible under the generated_conversions?

    public function registerMediaCollections(): void
    {
        $this->addMediaCollection('video')->singleFile();
    }
    $this->addMediaConversion('thumbnail')
            ->fit(Manipulations::FIT_CONTAIN, width: 720)
            ->extractVideoFrameAtSecond(4)
            ->performOnCollections('video');
    $this->addMediaConversion('timelapse')
            ->nonQueued()
             // somehow register/trigger a custom manipulation?
            ->performOnCollections('video');

Is it possible to achieve this? Any example?

0

There are 0 best solutions below