search

Home  >  Q&A  >  body text

Call to undefined method FFMpeg\Media\Video::addWatermark()

I'm trying to add a watermark to a video I own but I'm getting this error while applying the watermark

The library is installed and works with the commented code, but it doesn't work when trying to add a 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);
});

P粉567281015P粉567281015239 days ago423

reply all(1)I'll reply

  • P粉011360903

    P粉0113609032024-03-30 12:13:13

    Try using 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(...);

    reply
    0
  • Cancelreply