1

i am using laravel framework and also using ffmpeg php library. Actually i have done almost 70% of work. But the problem i faced is to show watermark at multiple areas on video. I have done the watermark on top-left corner that is running very fine on that video. But i want to add watermark in top-left, bottom-left, bottom-right. I have used this code for top-left watermark (for video):-

$inputVideo = public_path('input/airplane_flight_airport_panorama_1080.mp4');
$outputVideo = public_path('uploads/output.mp4');
$watermark = public_path('input/watermark.jpg');

$wmarkvideo = "ffmpeg -i ".$inputVideo." -i ".$watermark." -filter_complex ". '"overlay=x=(main_w-overlay_w):y=(main_h-overlay_h)/(main_h-overlay_h)"'." ".$outputVideo;
exec($wmarkvideo );

Please help me how can i add watermark on top-left, bottom-left, bottom-right in these areas. Thanks in advance :)

kunal
  • 4,122
  • 12
  • 40
  • 75

1 Answers1

1

This is the ffmpeg command you would use for multiple watermarks

ffmpeg -i inputVideo -i watermark-tr -i watermark-tl -i watermark-br -i watermark-bl 
       -filter_complex "[0][1]overlay=x=W-w:y=0[tr];
                        [tr][2]overlay=x=0:y=0[tl];
                        [tl][3]overlay=x=W-w:y=H-h[br];
                        [br][4]overlay=x=0:y=H-h"  outputfile

tr = top-right; tl = top-left; br = bottom-right; bl = bottomleft


With center as well,

ffmpeg -i inputVideo -i watermark-tr -i watermark-tl -i watermark-br -i watermark-bl -i watermark-c
       -filter_complex "[0][1]overlay=x=W-w:y=0[tr];
                        [tr][2]overlay=x=0:y=0[tl];
                        [tl][3]overlay=x=W-w:y=H-h[br];
                        [br][4]overlay=x=0:y=H-h[bl];
                        [bl][5]overlay=x=(W-w)/2:y=(H-h)/2"  outputfile
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • $mark = "ffmpeg -i ".$inputVideo." -i ".$watermark."-tr -i ".$watermark."-tl -i ".$watermark."-br -i ".$watermark."-bl -filter_complex ". '"[0][1]overlay=x=W-w:y=0[tr]; [tr][2]overlay=x=0:y=0[tl]; [tl][3]overlay=x=W-w:y=H-h[br]; [br][4]overlay=x=0:y=H-h"'." ".$outputVideo; exec($mark); – kunal Mar 07 '18 at 04:12
  • `watermark-tr` represents the filename for the top-right watermark. It has to be replaced entirely by the variable. Same for others. – Gyan Mar 07 '18 at 04:46
  • how can i add watermark in center also can you help me? – kunal Mar 07 '18 at 04:50
  • As you are expert in ffmpeg . Can you suggest me one thing i am uploading large videos in my website i want when user choose a large video file i want to compressed that file to less Mega bytes. i have not found any link ..... i able to compressed those files that are exists in my website directory. i want to compress those videos that user upload through form . Please help me – kunal Mar 07 '18 at 05:07
  • if you knw the answer please go to this link :- https://stackoverflow.com/questions/49144923/compress-the-video-using-ffmpeg-when-upload-using-php-form – kunal Mar 07 '18 at 05:46