From b08d782c99081086ff2f5ae3b3d8bad1caee5316 Mon Sep 17 00:00:00 2001 From: xufulong <839789740@qq.com> Date: Thu, 21 Nov 2019 02:03:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=B0=B4=E5=8D=B0:=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=88=86=E8=BE=A8=E7=8E=87=E3=80=81=E7=A0=81=E7=8E=87?= =?UTF-8?q?=E6=8F=90=E9=AB=98=E7=94=BB=E9=9D=A2=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 视频水印:设置分辨率、码率提高画面质量 --- .../com/frank/ffmpeg/activity/VideoHandleActivity.java | 4 +++- app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) 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(" ");//以空格分割为字符串数组 }