From ace10310954a984c2d7b4e204146b25d1691b430 Mon Sep 17 00:00:00 2001 From: xufuji456 <839789740@qq.com> Date: Tue, 8 Jun 2021 08:59:27 +0800 Subject: [PATCH] update the range of audio speed --- .../java/com/frank/ffmpeg/activity/AudioHandleActivity.kt | 2 +- app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt b/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt index 94d5cac..3a3e0fb 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt +++ b/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt @@ -216,7 +216,7 @@ class AudioHandleActivity : BaseActivity() { } R.id.btn_audio_speed//change audio speed -> { - val speed = 2.0f//from 0.5 to 2.0 + val speed = 2.0f // funny effect, range from 0.5 to 100.0 val speedPath = PATH + File.separator + "speed.mp3" commandLine = FFmpegUtil.changeAudioSpeed(srcFile, speedPath, speed) } 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 09b05b2..1edd382 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java +++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java @@ -523,8 +523,9 @@ public class FFmpegUtil { * @return change speed success or not */ public static String[] changeAudioSpeed(String inputPath, String outputPath, float speed) { - if (speed > 2 || speed < 0.5) { - throw new IllegalArgumentException("audio speed range is from 0.5 to 2"); + // atempo range [0.5, 100.0] + if (speed > 100 || speed < 0.5) { + throw new IllegalArgumentException("audio speed range is from 0.5 to 100"); } String speedCmd = "ffmpeg -i %s -filter_complex atempo=%.2f %s"; speedCmd = String.format(Locale.getDefault(), speedCmd, inputPath, speed, outputPath);