Protone Media logo

Laravel FFMpeg now supports watermarks out-of-the-box

Today a new version of Laravel FFMpeg has been released: version 7.3. It now has support for watermark built-in! You can add watermarks from your local or remote storage or even from the web. Positioning is easy. You can position it in a CSS-way, or you can use the built-in position constants. Let's take a look at both.

After opening your video file, you can call a new addWatermark method to open a watermark file. Like positioning elements with CSS, there are top, right, bottom, and left methods that also support offset values.

FFMpeg::open('lesson-1.mp4')
    ->addWatermark(function(WatermarkFactory $watermark) {
        $watermark->open('logo.png')
            ->right(25)
            ->bottom(25);
    });

Another way to position your watermark is by using the horizontalAlignment and verticalAlignment methods. Both require a constant and support an optional offset as well.

FFMpeg::open('lesson-2.mp4')
    ->addWatermark(function(WatermarkFactory $watermark) {
        $watermark->open('logo.png')
            ->horizontalAlignment(WatermarkFactory::LEFT, 25)
            ->verticalAlignment(WatermarkFactory::TOP, 25);
    });

You can read the full documentation at the GitHub repository.

I built this feature during a live coding session on YouTube. You can rewatch the whole process if you've missed it, and might even want to subscribe to my new YouTube channel for future sessions and lessons!

Related posts

Pascal Baljet on Twitter

Want to stay up-to-date on Laravel news and packages?

Follow me on Twitter: @pascalbaljet

© 2013-2020 Protone Media B.V.