/**
* 添加图片水印
*/
@Test
public void saveLogo(){
/**
* fontsize表示字体大小,
* fontfile表示字体格式,
* text中是文字水印显示的具体文字内容,
* x和y表示的是水印在视频中开始的位置,
* fontcolor表示水印中字体的颜色
*
* 右下角: x=w-tw-th:y=h-th
* 左下角: x=0:y=h-th
*/
// 命令
String commit = "$0 -i $1 -vf drawtext=fontcolor=white:fontsize=50:text='cat':x=w-tw-th:y=h-th:fontsize=50:fontcolor=white:shadowy=2 $2";
// ffmpeg
String ffmpegPath = "D:\\Java\\operSources\\ffmpeg-4.3.1\\bin\\ffmpeg.exe";
String str = commit.replace("$0", ffmpegPath)
.replace("$1", "D:\\image\\原图.jpg")
.replace("$2", "D:\\image\\修改后.jpg");
System.out.println(str);
Runtime runtime = Runtime.getRuntime();
try {
Process proce = runtime.exec(str);
} catch (IOException e) {
e.printStackTrace();
}
}
原图
结果图