add audio denoise effect

pull/190/head
xufuji456 4 years ago
parent 36f50a0b04
commit ae08fa3cce
  1. 8
      app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt
  2. 16
      app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
  3. 7
      app/src/main/res/layout/activity_audio_handle.xml
  4. 1
      app/src/main/res/values-en/strings.xml
  5. 3
      app/src/main/res/values/strings.xml

@ -104,7 +104,8 @@ class AudioHandleActivity : BaseActivity() {
R.id.btn_pcm_concat, R.id.btn_pcm_concat,
R.id.btn_audio_speed, R.id.btn_audio_speed,
R.id.btn_audio_echo, R.id.btn_audio_echo,
R.id.btn_audio_tremolo R.id.btn_audio_tremolo,
R.id.btn_audio_denoise
) )
} }
@ -235,6 +236,11 @@ class AudioHandleActivity : BaseActivity() {
val tremoloPath = PATH + File.separator + "tremolo.mp3" val tremoloPath = PATH + File.separator + "tremolo.mp3"
commandLine = FFmpegUtil.audioTremolo(srcFile, frequency, depth, tremoloPath) commandLine = FFmpegUtil.audioTremolo(srcFile, frequency, depth, tremoloPath)
} }
R.id.btn_audio_denoise
-> {
val noisePath = PATH + File.separator + "denoise.mp3"
commandLine = FFmpegUtil.audioDenoise(srcFile, noisePath)
}
else -> { else -> {
} }
} }

@ -120,6 +120,22 @@ public class FFmpegUtil {
return tremoloCmd.split(" "); return tremoloCmd.split(" ");
} }
/**
* Denoise audio samples with FFT
*
* @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
// nf: noise floor in dB, [-80 to -20], Default value is -50 dB
// nt: noise type {w:white noise v:vinyl noise s:shellac noise}
String fftDenoiseCmd = "ffmpeg -i %s -af afftdn %s";
fftDenoiseCmd = String.format(Locale.getDefault(), fftDenoiseCmd, inputPath, outputPath);
return fftDenoiseCmd.split(" ");
}
/** /**
* mux audio and video together * mux audio and video together
* *

@ -90,6 +90,13 @@
android:text="@string/audio_tremolo" android:text="@string/audio_tremolo"
android:layout_marginTop="10dp" /> android:layout_marginTop="10dp" />
<Button
android:id="@+id/btn_audio_denoise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio_denoise"
android:layout_marginTop="10dp" />
</LinearLayout> </LinearLayout>
<include <include

@ -11,6 +11,7 @@
<string name="audio_speed">Audio speed</string> <string name="audio_speed">Audio speed</string>
<string name="audio_echo">Echo effect</string> <string name="audio_echo">Echo effect</string>
<string name="audio_tremolo">Tremolo effect</string> <string name="audio_tremolo">Tremolo effect</string>
<string name="audio_denoise">Audio denoise</string>
<string name="audio_effect">Audio effect</string> <string name="audio_effect">Audio effect</string>
<string name="audio_equalizer">Audio equalizer:</string> <string name="audio_equalizer">Audio equalizer:</string>
<string name="audio_style">Audio style:</string> <string name="audio_style">Audio style:</string>

@ -3,7 +3,7 @@
<string name="audio_transform">音频转码</string> <string name="audio_transform">音频转码</string>
<string name="audio_cut">音频剪切</string> <string name="audio_cut">音频剪切</string>
<string name="audio_concat">音频合并</string> <string name="audio_concat">音频合并</string>
<string name="audio_mix">频混合</string> <string name="audio_mix">乐混音</string>
<string name="audio_play">音频解码AudioTrack播放</string> <string name="audio_play">音频解码AudioTrack播放</string>
<string name="audio_opensl">音频解码OpenSL播放</string> <string name="audio_opensl">音频解码OpenSL播放</string>
<string name="audio_encode">PCM编码</string> <string name="audio_encode">PCM编码</string>
@ -11,6 +11,7 @@
<string name="audio_speed">音频速度</string> <string name="audio_speed">音频速度</string>
<string name="audio_echo">空灵效果</string> <string name="audio_echo">空灵效果</string>
<string name="audio_tremolo">惊悚效果</string> <string name="audio_tremolo">惊悚效果</string>
<string name="audio_denoise">音频降噪</string>
<string name="audio_effect">音乐均衡器</string> <string name="audio_effect">音乐均衡器</string>
<string name="audio_equalizer">均衡器:</string> <string name="audio_equalizer">均衡器:</string>
<string name="audio_style">风格:</string> <string name="audio_style">风格:</string>

Loading…
Cancel
Save