Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to configure ffmpeg to export spectrogram with information of the audio file (Read 4973 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to configure ffmpeg to export spectrogram with information of the audio file

I created the spectrogram for the audio file in ffmpeg, but it's not display the informations as I wish.
My code in BAT file:
set MyFiles=*.flac *.wav *.aif
FOR %%A IN (%MyFiles%) DO ffmpeg -i "%%A" -y -lavfi showspectrumpic=s=1100x500:mode=separate "%%~nxA.png"


Is there a way to configure ffmpeg, display spectrogram like image below:
(Display Frequency 22 kHz; Title in spectrogram | bitrate kbps | samplerate Hz | bitspersample bit | Channels )
 

Can someone help please?

Thanks for any guidance.

Re: How to configure ffmpeg to export spectrogram with information of the audio file

Reply #1
Only sample rate and channels(layout) are available to filter, but you could use additional filter like drawtext to write all info.

Re: How to configure ffmpeg to export spectrogram with information of the audio file

Reply #2
Only sample rate and channels(layout) are available to filter, but you could use additional filter like drawtext to write all info.
Great! Thank you very much!

I have inserted the title in spectrogram:
-vf drawtext=text='%%A':x=(w-tw)/2:y=(h-th)/2:fontfile=OpenSans-Regular.ttf

But parameters as: bitrate kbps | samplerate Hz | bitspersample bit | Channels
I did not found them in "ffmpeg -h"
Could you please guide me as how to insert code?

Re: How to configure ffmpeg to export spectrogram with information of the audio file

Reply #3
You could extract them with ffprobe.


Re: How to configure ffmpeg to export spectrogram with information of the audio file

Reply #5
How to use this on the command line for just one file?
I just tried this:

ffmpeg -i infile.flac -lavfi showspectrumpic=s=1400x800:mode=separate outfile.png

Works, but does not cover the full frequency spectrum. Any ideas?

Re: How to configure ffmpeg to export spectrogram with information of the audio file

Reply #6
How to use this on the command line for just one file?
I just tried this:

ffmpeg -i infile.flac -lavfi showspectrumpic=s=1400x800:mode=separate outfile.png

Works, but does not cover the full frequency spectrum. Any ideas?

The height in your case must be power of 2.

Re: How to configure ffmpeg to export spectrogram with information of the audio file

Reply #7
That explains it, thanks. (Now using 1024 instead of 800)

Re: How to configure ffmpeg to export spectrogram with information of the audio file

Reply #8
Hm... isn't ffplay better solution than ffmpeg?

Re: How to configure ffmpeg to export spectrogram with information of the audio file

Reply #9
ffplay, as name tells plays files only.

 

Re: How to configure ffmpeg to export spectrogram with information of the audio file

Reply #10
ffplay, as name tells plays files only.
Exactly. So, I am using ffplay for previews inside my batch file when want to see the final result of that what ffmpeg will do for me before it start.