Answers.Body: <p>You be better off not care about window functions, no one pays attention to the rendered audio spectrum. Therefore you need not to be analytically correct so you can let spectral leakages happen and just use the <code>rect</code> window. Which is the <a href="https://en.wikipedia.org/wiki/Window_function#Rectangular_window" rel="nofollow noreferrer">identity window</a>, simply put, FFmpeg doesn't do any windowing in this mode and performs plain <a href="https://en.wikipedia.org/wiki/Short-time_Fourier_transform" rel="nofollow noreferrer">STFT</a> on the audio waveform slicing each in <code>win_size</code> sized blocks.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-23T11:26:47.657Z
Answers.LastActivityDate: 2022-01-23T11:26:47.657Z
Answers.UserDisplayName: qam2048
Body: <p>I'm using <code>showfreqs</code> and various other audio viz filters to create cool spectrum visualizations for my self-released music.</p>
  
  <p>Going through the documentation, I see that there's a multitude of <code>win_func</code>s you can use with <code>showfreqs</code> (and others):
  <a href="https://ffmpeg.org/ffmpeg-filters.html#showfreqs" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-filters.html#showfreqs</a></p>
  
  <p>I tried reading about these different windowing functions on wikipedia:
  <a href="https://en.wikipedia.org/wiki/Window_function" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Window_function</a></p>
  
  <p>While I understand <em>generally</em> that you choose a windowing function based on how you want to handle spectral leakage,  I can't really understand the math that's involved here... it's over my head.</p>
  
  <p>So... my question really boils down to:</p>
  
  <p><strong>What's the right windowing function to use for visualizing music?</strong> Is there a best practice here? </p>
  
  <p><code>hanning</code> (the default) seems to work ok... I tried a few others but I'm having trouble actually observing what the differences are between them...</p>
  
Tags: <ffmpeg><visual-effects>
Title: FFMPEG: Choosing the right win_func for showfreqs
UserDisplayName: A K
ThreadText: # FFMPEG: Choosing the right win_func for showfreqs
  
  (Asked by: username_0 on 2019-06-16)
  
  I'm using `showfreqs` and various other audio viz filters to create cool spectrum visualizations for my self-released music.
  
  Going through the documentation, I see that there's a multitude of `win_func`s you can use with `showfreqs` (and others):
  <https://ffmpeg.org/ffmpeg-filters.html#showfreqs>
  
  I tried reading about these different windowing functions on wikipedia:
  <https://en.wikipedia.org/wiki/Window_function>
  
  While I understand *generally* that you choose a windowing function based on how you want to handle spectral leakage, I can't really understand the math that's involved here... it's over my head.
  
  So... my question really boils down to:
  
  **What's the right windowing function to use for visualizing music?** Is there a best practice here?
  
  `hanning` (the default) seems to work ok... I tried a few others but I'm having trouble actually observing what the differences are between them...
  
  **Tags:** ffmpeg, visual-effects
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-01-23. Score: 0
  
  You be better off not care about window functions, no one pays attention to the rendered audio spectrum. Therefore you need not to be analytically correct so you can let spectral leakages happen and just use the `rect` window. Which is the [identity window](https://en.wikipedia.org/wiki/Window_function#Rectangular_window), simply put, FFmpeg doesn't do any windowing in this mode and performs plain [STFT](https://en.wikipedia.org/wiki/Short-time_Fourier_transform) on the audio waveform slicing each in `win_size` sized blocks.
  
  
  ---
  
  