Skip to content

Commit

Permalink
feat: 更新java工具
Browse files Browse the repository at this point in the history
  • Loading branch information
hexleo committed Dec 1, 2020
1 parent 2e40175 commit dd4b80e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void createVideo(CommonArg commonArg){
// 由json变为bin文件
mp4BoxTool(input, commonArg.outputPath);
// 将bin文件合并到mp4里
result = mergeBin2Mp4(commonArg.outputPath + "/vapc.bin", commonArg.outputPath);
result = mergeBin2Mp4(commonArg, commonArg.outputPath + "/vapc.bin", commonArg.outputPath);
if (!result) {
TLog.i(TAG, "mergeBin2Mp4 fail");
return;
Expand Down Expand Up @@ -254,7 +254,7 @@ private void createVapcJson(CommonArg commonArg) {
*/
private boolean createMp4(CommonArg commonArg) throws Exception {
String path = commonArg.outputPath;
String[] cmd = new String[] {"ffmpeg", "-r", String.valueOf(commonArg.fps),
String[] cmd = new String[] {commonArg.ffmpegCmd, "-r", String.valueOf(commonArg.fps),
"-i", path + "/%03d.png",
"-pix_fmt", "yuv420p",
"-vcodec", "libx264",
Expand All @@ -275,8 +275,8 @@ private boolean createMp4(CommonArg commonArg) throws Exception {
* @param inputFile
* @throws Exception
*/
private boolean mergeBin2Mp4(String inputFile, String videoPath) throws Exception{
String[] cmd = new String[] {"mp4edit", "--insert", ":"+inputFile+":1", videoPath + "/tmp_video.mp4", videoPath + "/video.mp4"};
private boolean mergeBin2Mp4(CommonArg commonArg, String inputFile, String videoPath) throws Exception{
String[] cmd = new String[] {commonArg.mp4editCmd, "--insert", ":"+inputFile+":1", videoPath + "/tmp_video.mp4", videoPath + "/video.mp4"};
Process pro = Runtime.getRuntime().exec(cmd);
int result = pro.waitFor();
TLog.i(TAG, "mergeBin2Mp4 result=" + (result == 0? "success" : "fail"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public class CommonArg {
public static final int ORIN_H = 1; // 左右对齐
public static final int ORIN_V = 2; // 上下对齐

public String ffmpegCmd = "ffmpeg"; // ffmpeg 命令地址

public String mp4editCmd = "mp4edit"; // bento4 mp4edit 命令地址

public int version = 2;

public int orin = ORIN_H;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public static void main(String[] args) throws Exception {
*/
public static void animTool() {
final CommonArg commonArg = new CommonArg();
// ffmpeg 命令路径
commonArg.ffmpegCmd = "ffmpeg";
// bento4 mp4edit 命令路径
commonArg.mp4editCmd = "mp4edit";

// 视频对齐方式 ORIN_H = 左右对齐, ORIN_V 上下对齐
commonArg.orin = CommonArg.ORIN_H;
// 素材宽高 px
Expand Down

0 comments on commit dd4b80e

Please sign in to comment.