add super equalizer of audio effect

pull/190/head
xufuji456 4 years ago
parent 5351985116
commit 85d17ee351
  1. 14
      app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt
  2. 26
      app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
  3. 9
      app/src/main/res/layout/activity_audio_handle.xml
  4. 2
      app/src/main/res/values/strings.xml

@ -119,6 +119,7 @@ class AudioHandleActivity : BaseActivity() {
R.id.btn_audio_echo,
R.id.btn_audio_tremolo,
R.id.btn_audio_denoise,
R.id.btn_audio_equalizer,
R.id.btn_audio_silence,
R.id.btn_audio_volume
)
@ -256,6 +257,19 @@ class AudioHandleActivity : BaseActivity() {
val noisePath = PATH + File.separator + "denoise.mp3"
commandLine = FFmpegUtil.audioDenoise(srcFile, noisePath)
}
R.id.btn_audio_equalizer // equalizer plus
-> {
// key:band value:gain=[0-20]
val bandList = arrayListOf<String>()
bandList.add("6b=5")
bandList.add("8b=4")
bandList.add("10b=3")
bandList.add("12b=2")
bandList.add("14b=1")
bandList.add("16b=0")
val equalizePath = PATH + File.separator + "equalize.mp3"
commandLine = FFmpegUtil.audioEqualizer(srcFile, bandList, equalizePath)
}
R.id.btn_audio_silence //silence detect
-> {
commandLine = FFmpegUtil.audioSilenceDetect(srcFile)

@ -160,6 +160,32 @@ public class FFmpegUtil {
return volumeCmd.split(" ");
}
/**
* Apply 18 band of equalizer into audio
*
* @param inputPath input file
* @param bandList bandList
* @param outputPath output file
*/
public static String[] audioEqualizer(String inputPath, List<String> bandList, String outputPath) {
// unit: Hz gain:0-20
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1b | 2b | 3b | 4b | 5b | 6b | 7b | 8b | 9b |
| 65 | 92 | 131 | 185 | 262 | 370 | 523 | 740 | 1047 |
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 10b | 11b | 12b | 13b | 14b | 15b | 16b | 17b | 18b |
| 1480 | 2093 | 2960 | 4186 | 5920 | 8372 | 11840 | 16744 | 20000 |
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
StringBuilder builder = new StringBuilder();
for (String band:bandList) {
builder.append(band).append(":");
}
builder.deleteCharAt(builder.length()-1);
String equalizerCmd = "ffmpeg -i %s -af superequalizer=%s -y %s";
equalizerCmd = String.format(Locale.getDefault(), equalizerCmd, inputPath, builder.toString(), outputPath);
return equalizerCmd.split(" ");
}
/**
* mux audio and video together
*

@ -16,7 +16,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio_transform"
android:layout_marginTop="40dp" />
android:layout_marginTop="10dp" />
<Button
android:id="@+id/btn_cut"
@ -99,6 +99,13 @@
android:text="@string/audio_denoise"
android:layout_marginTop="10dp" />
<Button
android:id="@+id/btn_audio_equalizer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio_add_equalizer"
android:layout_marginTop="10dp" />
<Button
android:id="@+id/btn_audio_silence"
android:layout_width="wrap_content"

@ -2,7 +2,7 @@
<string name="app_name">FFmpegAndroid</string>
<string name="audio_transform">音频转码</string>
<string name="audio_cut">音频剪切</string>
<string name="audio_concat">音频合并</string>
<string name="audio_concat">音频拼接</string>
<string name="audio_mix">音乐混音</string>
<string name="audio_play">音频解码AudioTrack播放</string>
<string name="audio_opensl">音频解码OpenSL播放</string>

Loading…
Cancel
Save