From dd4b80e7a1a796b8840bff21d3d88185fd2d157c Mon Sep 17 00:00:00 2001 From: hexleo Date: Tue, 1 Dec 2020 15:46:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0java=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/qgame/playerproj/animtool/AnimTool.java | 8 ++++---- .../com/tencent/qgame/playerproj/animtool/CommonArg.java | 4 ++++ .../java/com/tencent/qgame/playerproj/animtool/Main.java | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/AnimTool.java b/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/AnimTool.java index 6c459a82..5abe40b2 100644 --- a/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/AnimTool.java +++ b/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/AnimTool.java @@ -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; @@ -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", @@ -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")); diff --git a/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/CommonArg.java b/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/CommonArg.java index 7bc0df8a..19ab4239 100644 --- a/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/CommonArg.java +++ b/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/CommonArg.java @@ -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; diff --git a/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/Main.java b/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/Main.java index c10ac77f..e06a4337 100644 --- a/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/Main.java +++ b/Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/Main.java @@ -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