Created
May 1, 2022 17:17
-
-
Save coderofsalvation/f3e3cb3ffa637594dd642b9fc6ee8469 to your computer and use it in GitHub Desktop.
ffmpeg example template for audio fft processing #filtergraph #batch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# the following mixes 2 FFT-expressions into a dry (FFT) signal | |
set -e | |
in=/tmp/somefile.wav | |
out="$in.ffmpeg.wav" | |
winsize=1024 | |
fft_a_r="real='0'" | |
fft_a_i="imag='tanh(re / 8) * lt(b,4)" # bins 0-4 | |
fft_b_r="real='0'" | |
fft_b_i="imag='tanh(re * 1.8) * gt(b,150) * lt(b,512)'" # bins 150-512 | |
filter='channelsplit=channel_layout=stereo [aL][aR]; | |
[aL] asplit=outputs=3 [as1L] [as2L] [as3L]; | |
[aR] asplit=outputs=3 [as1R] [as2R] [as3R]; | |
[as1L] afftfilt=overlap=0.9:win_size='$winsize':real=re*1:imag=im*1 [as1LFFT]; | |
[as1R] afftfilt=overlap=0.9:win_size='$winsize':real=re*1:imag=im*1 [as1RFFT]; | |
[as2L] afftfilt=overlap=0.9:win_size='$winsize':'$fft_a_r':'$fft_a_i' [as2LFFT]; | |
[as2R] afftfilt=overlap=0.9:win_size='$winsize':'$fft_a_r':'$fft_a_i' [as2RFFT]; | |
[as3L] afftfilt=overlap=0.9:win_size='$winsize':'$fft_b_r':'$fft_b_i' [as3LFFT]; | |
[as3R] afftfilt=overlap=0.9:win_size='$winsize':'$fft_b_r':'$fft_b_i' [as3RFFT]; | |
[as1LFFT][as1RFFT] join=inputs=2:channel_layout=stereo [out1]; | |
[as2LFFT][as2RFFT] join=inputs=2:channel_layout=stereo [out2]; | |
[as3LFFT][as3RFFT] join=inputs=2:channel_layout=stereo [out3]; | |
[out1][out2][out3] amix=inputs=3,volumedetect | |
' | |
timeout 2s ffplay -i "$in" | |
set -x | |
ffmpeg -i "$in" -af "$(echo "$filter" | tr -d '\n')" -ac 2 -y "$out" | |
timeout 2s ffplay -i "$out" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment