Преглед изворни кода

update FFmpegWrapper#m3u8ToMp4

reghao пре 8 месеци
родитељ
комит
074541f15e
1 измењених фајлова са 12 додато и 3 уклоњено
  1. 12 3
      media/src/main/java/cn/reghao/jutil/media/FFmpegWrapper.java

+ 12 - 3
media/src/main/java/cn/reghao/jutil/media/FFmpegWrapper.java

@@ -197,9 +197,18 @@ public class FFmpegWrapper {
         return Shell.exec(cmd);
     }
 
-    public static int m3u8ToMp4(String m3u8Dir, String destPath) {
-        String cmd = String.format("%s -allowed_extensions ALL -protocol_whitelist \"file,http,crypto,tcp\" " +
-                "-i \"%s\" -c:a aac -c:v libx264 -f mp4 \"%s\"", ffmpeg, m3u8Dir, destPath);
+    /**
+     * 将 m3u8 的 ts 分片合并为 mp4 文件
+     *
+     * @param tsListPath 格式
+     * file a/b/0.ts
+     * file a/b/1.ts
+     * @return
+     * @date 2025-07-09 17:37:07
+     */
+    public static int m3u8ToMp4(String tsListPath, String destPath) {
+        String cmd = String.format("%s -loglevel error " +
+                "-f concat -safe 0 -i \"%s\" -c:a aac -c:v libx264 \"%s\"", ffmpeg, tsListPath, destPath);
         return Shell.exec(cmd);
     }
 }