2

I would like to "convert" audio to video visualisation (oscilloscope or waveform) sort of like some media players have.

I read this thread on how to do so with ffmpeg: How do I turn audio into video (that is, show the waveforms in a video)?

I have never used ffmpeg before and having read the previous thread I am still very confused with how to do it. As far as I know, ffmpeg does not have a GUI, so its a bit hard to understand.

I tried the following code:

ffmpeg -i audio.mp3 -filter_complex "[0:a]avectorscope=s=1080x1080,format=yuv420p[vid]" -map "[vid]" -map 0:a -codec:v libx264 -crf 18 -preset fast -codec:a aac -strict -2 -b:a 192k output.mp4

But the result i get is just a vertical line (the avectorscope does not spread out).

enter image description here

I have made sure that the audio is in stereo and has a high amplitude. I guess there is something I am missing in the code...

Also I would really like to know how I can change the background color from black to something custom.

  • Have you used a shell or, on Windows, the command line? – Gyan Jan 12 '16 at 5:26
  • Can you provide your input file? – llogan Jan 12 '16 at 22:16
  • Not really because the content is private. It is a stereo MP3 file at 320kbps in 44.1 Hz – Arete Jan 14 '16 at 0:38
2

The following command shows a video with a waveform of the corresponding audio:

ffmpeg -i input.mp4 -filter_complex "[0:a]showwaves=s=1280x720,format=yuv420p[vid]" -map "[vid]" -map 0:a -codec:v libx264 -crf 18 -preset fast -codec:a aac -strict -2 -b:a 192k output.mp4

I replaced avectorscope with showwaves: avectorscope is for showing the difference between stereo pairs. Try showcqt,showfreqs,showspectrum for other visualization effects.

  • Thanks a lot. Do you know any way to change the background from black to a custom color? – Arete Jan 14 '16 at 21:43
  • 1
    @Arete For what effect, specifically? Some, or at least showfreqs, already have alpha and you just need to overlay it over a color source. Otherwise you could try format filter and colorkey or chromakey filters. – llogan Jan 14 '16 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.