6
votes

I'm trying to write libavfilter bindings to convert an arbitrary audio file into a raw frequency (spectrum) data to do subsequent audio analysis. Is there anything built-in ffmpeg or libavfilter to output binary frequency data, rather than a proper audio/video file?

FFmpeg has a few built-in filters that perform an FFT such as afftfilt and showfreqs, however these filters always convert output back to video or audio. What I need is something like the afftfilt filter, but which dumps the raw FFT data, rather than recode it back to PCM.

1
When you say binary frequency data, what format is that going to take? Would it be a sequence of float pairs for real and imaginary parts? or would it be frequency bin and magnitude pairs?fdcpp
Any format works for me, I guess re+im pairs as returned by fft would make sense.Jeroen
Is there a reason for the limitation to FFmpeg / libav? For instance, would there be a problem in using FFTW where complex output is just an array of 2 doubles?fdcpp
Just putting in a note that you may want Constant Q data instead of FT data, but the output would still be an array/stream of complex numbers.Brannon
if this was any success, answering could help meYadu

1 Answers

1
votes

Depending on how accurate you need the FFT to be, and whether you need the imaginary part, you could macgyver something out of the showspectrum filter output - have it output to raw bitmaps and treat these as byte arrays.