modify: add subtitle into video

dev
xufuji456 3 years ago
parent 00df3801e7
commit e0a3e271ad
  1. 2
      app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt
  2. 2
      app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java

@ -339,7 +339,7 @@ class VideoHandleActivity : BaseActivity() {
R.id.btn_add_subtitle//add subtitle into video R.id.btn_add_subtitle//add subtitle into video
-> { -> {
val subtitlePath = PATH + File.separator + "test.ass" 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) commandLine = FFmpegUtil.addSubtitleIntoVideo(srcFile, subtitlePath, addSubtitlePath)
} }
R.id.btn_rotate// set the rotate degree of video R.id.btn_rotate// set the rotate degree of video

@ -702,7 +702,7 @@ public class FFmpegUtil {
} }
public static String[] addSubtitleIntoVideo(String inputPath, String subtitlePath, String outputPath) { 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); subtitleCmd = String.format(subtitleCmd, inputPath, subtitlePath, outputPath);
return subtitleCmd.split(" "); return subtitleCmd.split(" ");
} }

Loading…
Cancel
Save