diff --git a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java index 0084e74..08a9da4 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java +++ b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java @@ -144,7 +144,9 @@ public class VideoHandleActivity extends BaseActivity { //1、图片 String photo = PATH + File.separator + "launcher.png"; String photoMark = PATH + File.separator + "photoMark.mp4"; - commandLine = FFmpegUtil.addWaterMark(srcFile, photo, photoMark); + String mResolution = "720x1280"; + int bitRate = 1024; + commandLine = FFmpegUtil.addWaterMark(srcFile, photo, mResolution, bitRate, photoMark); //2、文字 // String text = "Hello,FFmpeg"; // String textPath = PATH + File.separator + "text.jpg"; diff --git a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java index 1cadd86..a580859 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java +++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java @@ -162,9 +162,10 @@ public class FFmpegUtil { * @param targetFile 目标文件 * @return 添加水印后的文件 */ - public static String[] addWaterMark(String srcFile, String waterMark, String targetFile){ - String waterMarkCmd = "ffmpeg -i %s -i %s -filter_complex overlay=0:0 %s"; - waterMarkCmd = String.format(waterMarkCmd, srcFile, waterMark, targetFile); + public static String[] addWaterMark(String srcFile, String waterMark, String resolution, int bitRate, String targetFile){ + String mBitRate = String.valueOf(bitRate) + "k"; + String waterMarkCmd = "ffmpeg -i %s -i %s -s %s -b:v %s -filter_complex overlay=0:0 %s"; + waterMarkCmd = String.format(waterMarkCmd, srcFile, waterMark, resolution, mBitRate, targetFile); return waterMarkCmd.split(" ");//以空格分割为字符串数组 }