From b57acdc1faefb0c31b90298e0a25d99da3cc7410 Mon Sep 17 00:00:00 2001 From: xufuji456 <839789740@qq.com> Date: Wed, 30 Jun 2021 00:06:01 +0800 Subject: [PATCH] cut video: copy all tracks of audio --- app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java index 45a147b..e925ceb 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java +++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java @@ -306,7 +306,11 @@ public class FFmpegUtil { * @return cut video success or not */ public static String[] cutVideo(String inputPath, int startTime, int duration, String outputPath) { - String cutVideoCmd = "ffmpeg -ss %d -accurate_seek -t %d -i %s -acodec copy -vcodec copy -avoid_negative_ts 1 %s"; + // -map 0 -codec copy (copy all tracks) + // -map 0:v -vcodec copy (copy track of video) + // -map 0:a -acodec copy (copy all tracks of audio) + // -map 0:s -scodec copy (copy all tracks of subtitle) + String cutVideoCmd = "ffmpeg -ss %d -accurate_seek -t %d -i %s -map 0 -codec copy -avoid_negative_ts 1 %s"; cutVideoCmd = String.format(Locale.getDefault(), cutVideoCmd, startTime, duration, inputPath, outputPath); return cutVideoCmd.split(" "); }