Browse Source

feat: java工具支持h265

hexleo 5 years ago
parent
commit
0b284c0002

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

@@ -265,15 +265,29 @@ public class AnimTool {
      * @throws Exception
      */
     private boolean createMp4(CommonArg commonArg, String videoPath, String frameImagePath) throws Exception {
-        String[] cmd = new String[] {commonArg.ffmpegCmd, "-r", String.valueOf(commonArg.fps),
-                "-i", frameImagePath + "%03d.png",
-                "-pix_fmt", "yuv420p",
-                "-vcodec", "libx264",
-                "-b:v", "3000k",
-                "-profile:v", "baseline",
-                "-level", "3.0",
-                "-bf", "0",
-                "-y", videoPath + TEM_VIDEO_FILE};
+        String[] cmd = null;
+        if (commonArg.enableH265) {
+            cmd = new String[] {commonArg.ffmpegCmd, "-r", String.valueOf(commonArg.fps),
+                    "-i", frameImagePath + "%03d.png",
+                    "-pix_fmt", "yuv420p",
+                    "-vcodec", "libx265",
+                    "-b:v", "2000k",
+                    "-profile:v", "main",
+                    "-level", "4.0",
+                    "-tag:v", "hvc1",
+                    "-bufsize", "2000k",
+                    "-y", videoPath + TEM_VIDEO_FILE};
+        } else {
+            cmd = new String[]{commonArg.ffmpegCmd, "-r", String.valueOf(commonArg.fps),
+                    "-i", frameImagePath + "%03d.png",
+                    "-pix_fmt", "yuv420p",
+                    "-vcodec", "libx264",
+                    "-b:v", "3000k",
+                    "-profile:v", "baseline",
+                    "-level", "3.0",
+                    "-bf", "0",
+                    "-y", videoPath + TEM_VIDEO_FILE};
+        }
 
         Process pro = Runtime.getRuntime().exec(cmd);
         int result = pro.waitFor();

+ 2 - 0
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/CommonArg.java

@@ -24,6 +24,8 @@ public class CommonArg {
 
     public String mp4editCmd = "mp4edit"; // bento4 mp4edit 命令地址
 
+    public boolean enableH265 = false; // 是否开启h265
+
     public int version = 2;
 
     public int orin = ORIN_H;