这里使用FFmpeg
1、什么是FFmpeg
2、视频增加图片水印语法:
ffmpeg -i 0902-23.mp4 -vf "movie=warter_image_s.png[watermark];[in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10[out] " -vcodec mpeg4 -b:v 2000k 0902-23-warter2.mp4
3、实际应用
public function getWaterVideo($fileName,$videoName){
//水印视频存储位置
$tmp_dir = BASE_UPLOAD_PATH . DS . 'water_tmp/';
@unlink($tmp_dir . $videoName . '-warter2.mp4');
// $x = 18;
// $y = 15;
$str = 'ffmpeg -i ' .getVideoAliUrl($fileName). ' -vf "movie='.$tmp_dir.'water_logo.png[watermark];[in][watermark] overlay=18:15[out] " -vcodec mpeg4 -b:v 2000k ' .$tmp_dir . $videoName . '-warter2.mp4';
exec($str, $out, $status);
if($status){
return false;
}else{
return $videoName . '-warter2.mp4';
}
}