6

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.

Jeroen Ooms
  • 31,998
  • 35
  • 134
  • 207
  • 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 Jan 06 '20 at 20:10
  • Any format works for me, I guess re+im pairs as returned by fft would make sense. – Jeroen Ooms Jan 07 '20 at 13:26
  • Is there a reason for the limitation to FFmpeg / libav? For instance, would there be a problem in using [FFTW](http://www.fftw.org) where [complex output is just an array of 2 doubles](http://www.fftw.org/fftw3_doc/Complex-numbers.html#Complex-numbers)? – fdcpp Jan 07 '20 at 15:55
  • 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 Jan 08 '20 at 19:16
  • if this was any success, answering could help me – Yadu Apr 16 '20 at 07:35

1 Answers1

1

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.