update the range of audio speed

pull/190/head
xufuji456 3 years ago
parent 1562eef254
commit ace1031095
  1. 2
      app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt
  2. 5
      app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java

@ -216,7 +216,7 @@ class AudioHandleActivity : BaseActivity() {
} }
R.id.btn_audio_speed//change audio speed 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" val speedPath = PATH + File.separator + "speed.mp3"
commandLine = FFmpegUtil.changeAudioSpeed(srcFile, speedPath, speed) commandLine = FFmpegUtil.changeAudioSpeed(srcFile, speedPath, speed)
} }

@ -523,8 +523,9 @@ public class FFmpegUtil {
* @return change speed success or not * @return change speed success or not
*/ */
public static String[] changeAudioSpeed(String inputPath, String outputPath, float speed) { public static String[] changeAudioSpeed(String inputPath, String outputPath, float speed) {
if (speed > 2 || speed < 0.5) { // atempo range [0.5, 100.0]
throw new IllegalArgumentException("audio speed range is from 0.5 to 2"); 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"; String speedCmd = "ffmpeg -i %s -filter_complex atempo=%.2f %s";
speedCmd = String.format(Locale.getDefault(), speedCmd, inputPath, speed, outputPath); speedCmd = String.format(Locale.getDefault(), speedCmd, inputPath, speed, outputPath);

Loading…
Cancel
Save