How to put the watermark in Video using PHP
In this article, I will share with you how to put the watermark in Video in PHP.
First install PHP-FFMpeg is through Composer. Below is the command
composer require php-ffmpeg/php-ffmpeg
#1: Example
<?php
require 'vendor/autoload.php';
$ffmpeg = FFMpeg\FFMpeg::create(array(
'ffmpeg.binaries' => 'C:/ffmpeg/bin/ffmpeg.exe',
'ffprobe.binaries' => 'C:/ffmpeg/bin/ffprobe.exe',
'timeout' => 3600,
'ffmpeg.threads' => 12,
), @$logger);
$video = $ffmpeg->open('video.mpg');
$watermarkPath = "logo.jpg";
$video->filters()->watermark($watermarkPath, array(
'position' => 'relative',
'top' => 15,
'right' => 40,
));
$video
->save(new FFMpeg\Format\Video\X264(), 'export-x264.mp4')
->save(new FFMpeg\Format\Video\WMV(), 'export-wmv.wmv')
->save(new FFMpeg\Format\Video\WebM(), 'export-webm.webm');
?>
I hope it will help you.
Copyright 2024 ErrorGram