How can I make the live spectrogram that ffplay renders while playing audio use colours?
Asked
Active
Viewed 333 times
1 Answers
3
The showspectrum filter is what you're looking for.
To force ffplay to use colours:
ffplay -f lavfi "amovie=audio.m4a,asplit[a][out0];[a]showspectrum=color=intensity:slide=1[out1]"
outN
- non-documented output link names.
To generate video:
ffmpeg -i audio.m4a -lavfi showspectrum=color=magma:slide=1 spectrum.mp4

seeker
- 806
- 4
- 7
-
The ffplay command shows the spectrum in colour, but doesn't play the audio – theonlygusti Dec 10 '22 at 01:54
-
Just add the audio stream :) See updated answer. – seeker Dec 10 '22 at 08:42
-
The video generated ends, before all the last graphics is out of the scope (and the window fully black). How can is this to control, is there a way to make a video which is for some seconds longer than the audio? – Student May 09 '23 at 18:26
-
1@Student, to make the resulting video longer you should add the longer input for the `showspectrum` filter, e.g. you can pad the source audio with silence: `ffmpeg -i audio.mp3 -filter_complex '[0:a]apad=pad_dur=5s[a_padded];[a_padded]showspectrum=color=magma:slide=1' spectrum.mp4`. Moreover to smooth the video's end you may apply fade out filter: `[0:a]apad=pad_dur=5s[a_padded];[a_padded]showspectrum=color=magma:slide=1[spectrum];[spectrum]fade=type=out:start_frame=130:nb_frames=56`. Calculations of the offset from the end is on your own ;) – seeker May 16 '23 at 15:18