From e0a3e271ad6ccbbeae88d3162fbc24432c984057 Mon Sep 17 00:00:00 2001 From: xufuji456 <839789740@qq.com> Date: Thu, 26 Aug 2021 00:03:33 +0800 Subject: [PATCH] modify: add subtitle into video --- .../main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt | 2 +- app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt index b04bf5d..2495da4 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt +++ b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt @@ -339,7 +339,7 @@ class VideoHandleActivity : BaseActivity() { R.id.btn_add_subtitle//add subtitle into video -> { val subtitlePath = PATH + File.separator + "test.ass" - val addSubtitlePath = PATH + File.separator + "subtitle" + suffix + val addSubtitlePath = PATH + File.separator + "subtitle.mkv" commandLine = FFmpegUtil.addSubtitleIntoVideo(srcFile, subtitlePath, addSubtitlePath) } R.id.btn_rotate// set the rotate degree of video 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 0e97cfa..3b41b6e 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java +++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java @@ -702,7 +702,7 @@ public class FFmpegUtil { } public static String[] addSubtitleIntoVideo(String inputPath, String subtitlePath, String outputPath) { - String subtitleCmd = "ffmpeg -i %s -vf subtitles=%s %s"; + String subtitleCmd = "ffmpeg -i %s -i %s -map 0:v -map 0:a -map 1:s -c copy %s"; subtitleCmd = String.format(subtitleCmd, inputPath, subtitlePath, outputPath); return subtitleCmd.split(" "); }