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 d49ceef..ac30485 100644
--- a/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt
+++ b/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt
@@ -103,7 +103,8 @@ class AudioHandleActivity : BaseActivity() {
R.id.btn_audio_encode,
R.id.btn_pcm_concat,
R.id.btn_audio_speed,
- R.id.btn_audio_echo
+ R.id.btn_audio_echo,
+ R.id.btn_audio_tremolo
)
}
@@ -221,12 +222,19 @@ class AudioHandleActivity : BaseActivity() {
val speedPath = PATH + File.separator + "speed.mp3"
commandLine = FFmpegUtil.changeAudioSpeed(srcFile, speedPath, speed)
}
- R.id.btn_audio_echo//setting echo effect
+ R.id.btn_audio_echo // setting echo effect
-> {
val echo = 1000 // echo effect, range from 0 to 90000
val echoPath = PATH + File.separator + "echo.mp3"
commandLine = FFmpegUtil.audioEcho(srcFile, echo, echoPath)
}
+ R.id.btn_audio_tremolo //tremolo effect
+ -> {
+ val frequency = 5 // range from 0.1 to 20000.0
+ val depth = 0.9f // range from 0 to 1
+ val tremoloPath = PATH + File.separator + "tremolo.mp3"
+ commandLine = FFmpegUtil.audioTremolo(srcFile, frequency, depth, tremoloPath)
+ }
else -> {
}
}
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 eb1b8f4..9303013 100644
--- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
+++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
@@ -103,6 +103,23 @@ public class FFmpegUtil {
return echoCmd.split(" ");
}
+ /**
+ * Set tremolo effect, sinusoidal amplitude modulation
+ *
+ * @param inputPath input file
+ * @param frequency frequency
+ * @param depth depth
+ * @param outputPath output file
+ * @return mix success or not
+ */
+ public static String[] audioTremolo(String inputPath, int frequency, float depth, String outputPath) {
+ // frequency [0.1, 20000.0], Default is 5
+ // depth (0, 1], Default is 0.5
+ String tremoloCmd = "ffmpeg -i %s -af tremolo=%d:%f %s";
+ tremoloCmd = String.format(Locale.getDefault(), tremoloCmd, inputPath, frequency, depth, outputPath);
+ return tremoloCmd.split(" ");
+ }
+
/**
* mux audio and video together
*
diff --git a/app/src/main/res/layout/activity_audio_handle.xml b/app/src/main/res/layout/activity_audio_handle.xml
index 962b4f9..32dfabe 100644
--- a/app/src/main/res/layout/activity_audio_handle.xml
+++ b/app/src/main/res/layout/activity_audio_handle.xml
@@ -58,7 +58,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio_encode"
- android:layout_marginTop="10dp" />
+ android:layout_marginTop="10dp"
+ android:visibility="gone"/>
+
+
PCM concat
Audio speed
Echo effect
+ Tremolo effect
Audio effect
Audio equalizer:
Audio style:
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cc4f8d3..d438f6f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -10,6 +10,7 @@
PCM合并
音频速度
空灵效果
+ 惊悚效果
音乐均衡器
均衡器:
风格: