From b736ba647a2248b83a0f303591787249fd227969 Mon Sep 17 00:00:00 2001 From: Super <986386695@qq.com> Date: Fri, 29 May 2020 07:40:33 +0800 Subject: [PATCH] =?UTF-8?q?RxFFmpegCommandList=E6=9E=84=E5=BB=BA=E5=91=BD?= =?UTF-8?q?=E4=BB=A4build(boolean=20isLog)=E6=96=B0=E5=A2=9EisLog,?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E6=9E=84=E5=BB=BA=E5=90=8E=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E5=91=BD=E4=BB=A4=E8=A1=8C=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- configs.gradle | 4 +- .../rxffmpeg/RxFFmpegCommandList.java | 41 ++++++++++++++++++- .../rxffmpeg/RxFFmpegCommandSupport.java | 21 +++++++--- 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 068da41..5033d67 100644 --- a/README.md +++ b/README.md @@ -87,10 +87,10 @@ dependencies { //以下两个选一个即可 //完整版 - implementation 'com.github.microshow:RxFFmpeg:4.2.0' + implementation 'com.github.microshow:RxFFmpeg:4.3.0' //极速版 (预计占用 4M 左右空间) - implementation 'com.github.microshow:RxFFmpeg:4.2.0-lite' + implementation 'com.github.microshow:RxFFmpeg:4.3.0-lite' } ``` diff --git a/configs.gradle b/configs.gradle index 00495a2..bbd6e5a 100644 --- a/configs.gradle +++ b/configs.gradle @@ -11,8 +11,8 @@ ext { //支持包版本 supportLibValue = "28.0.0" //应用 versionCode - versionCodeValue = 420 + versionCodeValue = 430 //应用 version 名称,更多设置里显示的 - versionNameValue = "4.2.0" + versionNameValue = "4.3.0" } \ No newline at end of file diff --git a/rxffmpeg/src/main/java/io/microshow/rxffmpeg/RxFFmpegCommandList.java b/rxffmpeg/src/main/java/io/microshow/rxffmpeg/RxFFmpegCommandList.java index 030b48f..1395d27 100644 --- a/rxffmpeg/src/main/java/io/microshow/rxffmpeg/RxFFmpegCommandList.java +++ b/rxffmpeg/src/main/java/io/microshow/rxffmpeg/RxFFmpegCommandList.java @@ -1,9 +1,13 @@ package io.microshow.rxffmpeg; +import android.util.Log; + import java.util.ArrayList; /** - * 指令集合 + * 指令集合, + * 默认会加上 ffmpeg -y,如果想去除默认的指令可以调用clearCommands()清除 + *

* Created by Super on 2019/4/5. */ public class RxFFmpegCommandList extends ArrayList { @@ -17,15 +21,27 @@ public RxFFmpegCommandList() { /** * 清除命令集合 */ - public void clearCommands() { + public RxFFmpegCommandList clearCommands() { this.clear(); + return this; } + /** + * 追加命令 + * + * @param s cmd + * @return RxFFmpegCommandList + */ public RxFFmpegCommandList append(String s) { this.add(s); return this; } + /** + * 构建命令 + * + * @return - + */ public String[] build() { String[] command = new String[this.size()]; for (int i = 0; i < this.size(); i++) { @@ -34,4 +50,25 @@ public String[] build() { return command; } + /** + * 构建命令 + * + * @param isLog true:构建命令后 Log打印命令日志; false :不打印命令日志 + * @return - + */ + public String[] build(boolean isLog) { + String[] cmds = build(); + if (isLog) {//需要打印构建后的命令 + StringBuilder cmdLogStr = new StringBuilder(); + for (int i = 0; i < cmds.length; i++) { + cmdLogStr.append(cmds[i]); + if (i < cmds.length - 1) { + cmdLogStr.append(" "); + } + } + Log.e("TAG_FFMPEG", "cmd: " + cmdLogStr.toString()); + } + return cmds; + } + } diff --git a/rxffmpeg/src/main/java/io/microshow/rxffmpeg/RxFFmpegCommandSupport.java b/rxffmpeg/src/main/java/io/microshow/rxffmpeg/RxFFmpegCommandSupport.java index 6d33f84..4c831dc 100644 --- a/rxffmpeg/src/main/java/io/microshow/rxffmpeg/RxFFmpegCommandSupport.java +++ b/rxffmpeg/src/main/java/io/microshow/rxffmpeg/RxFFmpegCommandSupport.java @@ -1,21 +1,32 @@ package io.microshow.rxffmpeg; +import android.text.TextUtils; + /** * RxFFmpeg 命令支持 * Created by Super on 2019/4/5. */ public class RxFFmpegCommandSupport { - public static String[] getBoxblur() { + /** + * 给视频加毛玻璃效果 + * + * @param inputPath 输入视频文件 + * @param outputPath 输出视频文件 + * @param boxblur blur效果调节,默认 "5:1" + * @param isLog true: 构建命令后 Log打印命令日志; false :不打印命令日志 + * @return cmds + */ + public static String[] getBoxblur(String inputPath, String outputPath, String boxblur, boolean isLog) { RxFFmpegCommandList cmdlist = new RxFFmpegCommandList(); cmdlist.append("-i"); - cmdlist.append("/storage/emulated/0/1/input.mp4"); + cmdlist.append(inputPath); cmdlist.append("-vf"); - cmdlist.append("boxblur=5:1"); + cmdlist.append("boxblur=" + (TextUtils.isEmpty(boxblur) ? "5:1" : boxblur)); cmdlist.append("-preset"); cmdlist.append("superfast"); - cmdlist.append("/storage/emulated/0/1/result.mp4"); - return cmdlist.build(); + cmdlist.append(outputPath); + return cmdlist.build(isLog); }