[FFmpeg-user] afreqshift

Michael Koch astroelectronic at t-online.de
Wed Oct 21 22:28:52 EEST 2020

Am 21.10.2020 um 21:02 schrieb Michael Koch:
> Am 21.10.2020 um 20:36 schrieb Paul B Mahol:
>> On Wed, Oct 21, 2020 at 08:14:50PM +0200, Michael Koch wrote:
>>> Hi,
>>> I'm just testing the new afreqshift filter.
>>> In my first test I did use only *.wav audio files. This test was 
>>> successful.
>>> In my next test I'm using MP4 files. First I make a test video with 
>>> a 5kHz
>>> tone:
>>> ffmpeg -f lavfi -i sine=f=5000:r=48000:d=5 -f lavfi -i color=black 
>>> -lavfi
>>> showspectrum=legend=1 -y test.mp4
>>> Now I try to shift the frequency down by 4kHz:
>>> ffmpeg -i test.mp4 -lavfi afreqshift=-4000,showspectrum=legend=1 -y 
>>> out.mp4
>>> The spectrum display is showing the expected 1kHz, but what I hear 
>>> is 5kHz.
>>> What's wrong with my command line? Why is the output of the afreqshift
>>> filter not mapped to the output file?
>> Something like this:
>> ffmpeg -i test.mp4 -lavfi 
>> "asplit=2[a][b],[b]afreqshift=-4000,showspectrum=legend=1[b]" -map 
>> "[a]" -map "[b]" -y out.mp4
>> You ignored fact that showspectrum is just A->V filter.
> That did also not work, the audio output is 5kHz. But thanks for 
> pointing me in the right direction. The asplit filter must be after 
> the afreqshift filter. This works:
> ffmpeg -i test.mp4 -lavfi 
> afreqshift=-4000,asplit[a][b];[b]showspectrum=legend=1 -map "[a]" -y 
> out.mp4

Would it be possible to add an option for deleting all frequencies which 
are smaller than the shift frequency, before shifting down? Because 
otherwise these freqencies are shifted into the negative frequency range 
and can still be heard.
Example: An audio signal contains normal audio frequencies in the 
[0...12kHz] range and ultrasonic frequencies in the [12kHz...20kHz] 
range. If we want to hear these ultrasonic frequencies, we must shift by 
-12kHz. But then the [0...12kHz] range is shifted to the [-12kHz...0] 
range which means we can still hear it. That could be solved by an 
additional steep highpass filter before the afreqshift filter.
Maybe it's easier to do that in the frequency domain in the afreqshift 


More information about the ffmpeg-user mailing list