Browse Source

feat: 更新java工具

hexleo 5 years ago
parent
commit
dd4b80e7a1

+ 4 - 4
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/AnimTool.java

@@ -182,7 +182,7 @@ public class AnimTool {
             // 由json变为bin文件
             // 由json变为bin文件
             mp4BoxTool(input, commonArg.outputPath);
             mp4BoxTool(input, commonArg.outputPath);
             // 将bin文件合并到mp4里
             // 将bin文件合并到mp4里
-            result = mergeBin2Mp4(commonArg.outputPath + "/vapc.bin", commonArg.outputPath);
+            result = mergeBin2Mp4(commonArg, commonArg.outputPath + "/vapc.bin", commonArg.outputPath);
             if (!result) {
             if (!result) {
                 TLog.i(TAG, "mergeBin2Mp4 fail");
                 TLog.i(TAG, "mergeBin2Mp4 fail");
                 return;
                 return;
@@ -254,7 +254,7 @@ public class AnimTool {
      */
      */
     private boolean createMp4(CommonArg commonArg) throws Exception {
     private boolean createMp4(CommonArg commonArg) throws Exception {
         String path = commonArg.outputPath;
         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",
                 "-i", path + "/%03d.png",
                 "-pix_fmt", "yuv420p",
                 "-pix_fmt", "yuv420p",
                 "-vcodec", "libx264",
                 "-vcodec", "libx264",
@@ -275,8 +275,8 @@ public class AnimTool {
      * @param inputFile
      * @param inputFile
      * @throws Exception
      * @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);
         Process pro = Runtime.getRuntime().exec(cmd);
         int result = pro.waitFor();
         int result = pro.waitFor();
         TLog.i(TAG, "mergeBin2Mp4 result=" + (result == 0? "success" : "fail"));
         TLog.i(TAG, "mergeBin2Mp4 result=" + (result == 0? "success" : "fail"));

+ 4 - 0
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_H = 1; // 左右对齐
     public static final int ORIN_V = 2; // 上下对齐
     public static final int ORIN_V = 2; // 上下对齐
 
 
+    public String ffmpegCmd = "ffmpeg"; // ffmpeg 命令地址
+
+    public String mp4editCmd = "mp4edit"; // bento4 mp4edit 命令地址
+
     public int version = 2;
     public int version = 2;
 
 
     public int orin = ORIN_H;
     public int orin = ORIN_H;

+ 5 - 0
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/Main.java

@@ -48,6 +48,11 @@ public class Main {
      */
      */
     public static void animTool() {
     public static void animTool() {
         final CommonArg commonArg = new CommonArg();
         final CommonArg commonArg = new CommonArg();
+        // ffmpeg 命令路径
+        commonArg.ffmpegCmd = "ffmpeg";
+        // bento4 mp4edit 命令路径
+        commonArg.mp4editCmd = "mp4edit";
+
         // 视频对齐方式 ORIN_H = 左右对齐, ORIN_V 上下对齐
         // 视频对齐方式 ORIN_H = 左右对齐, ORIN_V 上下对齐
         commonArg.orin = CommonArg.ORIN_H;
         commonArg.orin = CommonArg.ORIN_H;
         // 素材宽高 px
         // 素材宽高 px