add the tremolo effect

pull/190/head
xufuji456 4 years ago
parent ccc10ed69f
commit d7525073a7
  1. 12
      app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt
  2. 17
      app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
  3. 10
      app/src/main/res/layout/activity_audio_handle.xml
  4. 1
      app/src/main/res/values-en/strings.xml
  5. 1
      app/src/main/res/values/strings.xml

@ -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 -> {
}
}

@ -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
*

@ -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"/>
<Button
android:id="@+id/btn_pcm_concat"
@ -82,6 +83,13 @@
android:text="@string/audio_echo"
android:layout_marginTop="10dp" />
<Button
android:id="@+id/btn_audio_tremolo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio_tremolo"
android:layout_marginTop="10dp" />
</LinearLayout>
<include

@ -10,6 +10,7 @@
<string name="pcm_concat">PCM concat</string>
<string name="audio_speed">Audio speed</string>
<string name="audio_echo">Echo effect</string>
<string name="audio_tremolo">Tremolo effect</string>
<string name="audio_effect">Audio effect</string>
<string name="audio_equalizer">Audio equalizer:</string>
<string name="audio_style">Audio style:</string>

@ -10,6 +10,7 @@
<string name="pcm_concat">PCM合并</string>
<string name="audio_speed">音频速度</string>
<string name="audio_echo">空灵效果</string>
<string name="audio_tremolo">惊悚效果</string>
<string name="audio_effect">音乐均衡器</string>
<string name="audio_equalizer">均衡器:</string>
<string name="audio_style">风格:</string>

Loading…
Cancel
Save