0

I m trying to add a watermark to a video that I have but it's giving me this error while applying a watermark

The library is installed and working with the code commented but not when trying to add watermark

use FFMpeg\FFMpeg;
use ProtoneMedia\LaravelFFMpeg\Filters\WatermarkFactory;
    
$ffmpeg = FFMpeg::create();
$video = $ffmpeg->open(public_path('video-making-test/test1.mp4'));
//    $video
//        ->filters()
//        ->resize(new \FFMpeg\Coordinate\Dimension(320, 240))
//        ->synchronize();
//    $video
//        ->frame(\FFMpeg\Coordinate\TimeCode::fromSeconds(10))
//        ->save(public_path('video-making-test/results/frame.jpg'));
    $video->addWatermark(function(WatermarkFactory $watermark) {
    $watermark->fromDisk('public')
        ->open('video-making-test/logo.png')
        ->right(25)
        ->bottom(25);
});
Amir Khan
  • 401
  • 5
  • 13

2 Answers2

0

If you want to use addWatermark(), you need to do according to the suggestion of @shingo.

However, If you persit to use FFMpeg\FFMpeg, try using watermark method instead:

$video
    ->filters()
    ->watermark($watermarkPath, array(
        'position' => 'relative',
        'bottom' => 50,
        'right' => 50,
    ));
Khang Tran
  • 2,015
  • 3
  • 7
  • 10
0

Try to use ProtoneMedia\LaravelFFMpeg\Support\FFMpeg instead of FFMpeg\FFMpeg.

use ProtoneMedia\LaravelFFMpeg\Support\FFMpeg;

$video = FFMpeg::open(public_path('video-making-test/test1.mp4'));
$video->addWatermark(...);
shingo
  • 18,436
  • 5
  • 23
  • 42