From 835f092ab44d45801c69bf680e89d2d724cca640 Mon Sep 17 00:00:00 2001 From: xufulong <839789740@qq.com> Date: Sat, 23 May 2020 01:33:03 +0800 Subject: [PATCH] add cmd of changing video speed add cmd of changing video speed --- app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 dac8dc2..b0966c2 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java +++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java @@ -478,4 +478,12 @@ public class FFmpegUtil { return ffprobeCmd.split(" "); } + public static String[] changeSpeed(String inputFile, String outputFile, float speed) { + //audio atempo: 0.5--2 + float ptsFactor = 1/speed; + String speedCmd = "ffmpeg -i %s -filter_complex [0:v]setpts=%.2f*PTS[v];[0:a]atempo=%.2f[a] -map [v] -map [a] %s"; + speedCmd = String.format(Locale.getDefault(), speedCmd, inputFile, ptsFactor, speed, outputFile); + return speedCmd.split(" "); + } + }