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 f73437e..2b9c0ed 100644
--- a/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt
+++ b/app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt
@@ -105,7 +105,8 @@ class AudioHandleActivity : BaseActivity() {
R.id.btn_audio_speed,
R.id.btn_audio_echo,
R.id.btn_audio_tremolo,
- R.id.btn_audio_denoise
+ R.id.btn_audio_denoise,
+ R.id.btn_audio_silence
)
}
@@ -241,6 +242,10 @@ class AudioHandleActivity : BaseActivity() {
val noisePath = PATH + File.separator + "denoise.mp3"
commandLine = FFmpegUtil.audioDenoise(srcFile, noisePath)
}
+ R.id.btn_audio_silence
+ -> {
+ commandLine = FFmpegUtil.audioSilenceDetect(srcFile)
+ }
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 0015ee2..217c2de 100644
--- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
+++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
@@ -91,7 +91,6 @@ public class FFmpegUtil {
* @param inputPath input file
* @param delay delay to play
* @param outputPath output file
- * @return mix success or not
*/
public static String[] audioEcho(String inputPath, int delay, String outputPath) {
// in_gain (0, 1], Default is 0.6
@@ -110,7 +109,6 @@ public class FFmpegUtil {
* @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
@@ -125,7 +123,6 @@ public class FFmpegUtil {
*
* @param inputPath input file
* @param outputPath output file
- * @return mix success or not
*/
public static String[] audioDenoise(String inputPath, String outputPath) {
// nr: noise reduction in dB, [0.01 to 97], Default value is 12 dB
@@ -136,6 +133,19 @@ public class FFmpegUtil {
return fftDenoiseCmd.split(" ");
}
+ /**
+ * Detect silence of a chunk of audio
+ *
+ * @param inputPath input file
+ */
+ public static String[] audioSilenceDetect(String inputPath) {
+ // silence_start: 268.978
+ // silence_end: 271.048 | silence_duration: 2.06975
+ String silenceCmd = "ffmpeg -i %s -af silencedetect=noise=0.0001 -f null -";
+ silenceCmd = String.format(Locale.getDefault(), silenceCmd, inputPath);
+ return silenceCmd.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 003861c..a4abca0 100644
--- a/app/src/main/res/layout/activity_audio_handle.xml
+++ b/app/src/main/res/layout/activity_audio_handle.xml
@@ -44,14 +44,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio_play"
- android:layout_marginTop="10dp" />
+ android:layout_marginTop="10dp"
+ android:visibility="gone"/>
+ android:layout_marginTop="10dp"
+ android:visibility="gone"/>
+
+
Echo effect
Tremolo effect
Audio denoise
+ Silence detect
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 d5790bc..aaae0cc 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -12,6 +12,7 @@
空灵效果
惊悚效果
音频降噪
+ 静音检测
音乐均衡器
均衡器:
风格:
diff --git a/gradlew b/gradlew
index 9d82f78..1852d63 100644
--- a/gradlew
+++ b/gradlew
@@ -158,3 +158,4 @@ eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+