Skip to content

Commit

Permalink
RxFFmpegCommandList构建命令build(boolean isLog)新增isLog,控制构建后是否输出命令行日志信息
Browse files Browse the repository at this point in the history
  • Loading branch information
microshow committed May 28, 2020
1 parent 63ed32e commit a28384a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 9 deletions.
4 changes: 2 additions & 2 deletions configs.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ ext {
//支持包版本
supportLibValue = "28.0.0"
//应用 versionCode
versionCodeValue = 420
versionCodeValue = 430
//应用 version 名称,更多设置里显示的
versionNameValue = "4.2.0"
versionNameValue = "4.3.0"

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package io.microshow.rxffmpeg;

import android.util.Log;

import java.util.ArrayList;

/**
* 指令集合
* 指令集合,
* 默认会加上 ffmpeg -y,如果想去除默认的指令可以调用clearCommands()清除
* <p>
* Created by Super on 2019/4/5.
*/
public class RxFFmpegCommandList extends ArrayList<String> {
Expand All @@ -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++) {
Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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);
}


Expand Down

0 comments on commit a28384a

Please sign in to comment.