Webdesignbr
Webdesignbr

Reputation: 1

How do I make this Laravel Video watermark overlay function properly?

I have installed FFmpeg, and everything works and converts as I want it. However, when I tried with the watermark filter using the `ProtoneMediaLaravelFFMpegFiltersWatermarkFactory', it rendered without an issue, there is no watermark on it, and I cannot see any errors in the log file.

ConvertVideo.php

public function handle()
{
    $destination = '/' . $this->video->uid . '/' . $this->video->uid . '.m3u8';
    $low = (new X264('aac'))->setKiloBitrate(500);
    $high = (new X264('aac'))->setKiloBitrate(1000);

    FFMpeg::fromDisk('videos-temp')
        ->open($this->video->path)
        ->exportForHLS()
        ->addFormat($low, function ($filters) {
            $filters->resize(640, 480);
        })
        ->addFormat($high, function ($filters) {
            $filters->resize(1280, 720);
        })

       //watermark filter
        ->addWatermark(function(WatermarkFactory $watermark) {
            $watermark->fromDisk('videos-temp')
                ->open('videos-temp/logo.png')
                ->right(-125)
                ->bottom(25)
                ->width(100)
                ->height(100);
        })
        
        ->toDisk('videos')
        ->save($destination);

    $this->video->update([
        'processed' => true,
        'proccessed_file' => $this->video->uid . '.m3u8'
    ]);
}

I can convert the videos without an issue, but I cannot put a watermark on them. How would you guys, 'EXPERTS', solve this?

The full code is posted above. I have added the following watermark filter.

// watermark filter
->addWatermark(function(WatermarkFactory $watermark) {
    $watermark->fromDisk('videos-temp')
        ->open('videos-temp/logo.png')
        ->right(-125)
        ->bottom(25)
        ->width(100)
        ->height(100);
})

protonemedia/laravel-ffmpeg - Github

Upvotes: 0

Views: 155

Answers (1)

mp.hamid
mp.hamid

Reputation: 76

set watermark file with absolute path like this:

->addWatermark(function(WatermarkFactory $watermark) {
$watermark->fromDisk('videos-temp')
    ->open(storage_path('videos-temp/logo.png'))
    ->right(-125)
    ->bottom(25)
    ->width(100)
    ->height(100);
})

Upvotes: 0

Related Questions