I have this command I need to run as a background task on my server:

sox some-audio-file.foo -c 1 -t wav - | wav2png -w -o some-audio-file.png /dev/stdin

But I already have ffmpeg custom-compiled with all the right codecs (which was an ordeal and a half) and I'd prefer to avoid installing sox and having to go through the same ordeal again.

So I'm wondering, could I pipe my audio to wav2png using ffmpeg instead? What would be the equivalent ffmpeg command? I've been Googling on this for a while and nothing I've tried is working.

  • What does this do ? – Iain Sep 2 '14 at 5:50
  • wav2png produces an image representing the waveform of an audio file. The sox command decodes the file and puts it into an appropriate form for it to handle. – curtisdf Sep 2 '14 at 12:16

Choose your pipe

Untested example:

ffmpeg -i audio.foo -ac 1 -f wav - | wav2png -o audio.png /dev/stdin

Alternatively you could use the UNIX pipe access protocol.

ffmpeg -i audio.foo -ac 1 -f wav pipe: | wav2png -o audio.png /dev/stdin


  • -ac 1 was added to downmix to mono since currently with wav2png the max of all channels is used, but this option may be superfluous.

  • You can use any type of input that contains audio and that ffmpeg can decode.

  • If you just want to output a specific channel use the -map_channel option (example).

  • Simply using - instead of /dev/stdin may work, but I didn't get to try.

Visualizing audio

If you would like to create a video of the waveform use the showwaves filter.

ffmpeg -i audio.foo -filter_complex \
"[0:a]showwaves=mode=line,format=yuv420p[v]" \
-map "[v]" -map 0:a -c:a copy output.mp4

Or use a combination of filters: screenshot of video visualizing music

ffmpeg -i input.mp3 -filter_complex \
"[0:a]avectorscope=s=640x518,pad=1280:720[vs]; \
 [0:a]showspectrum=mode=separate:color=intensity:scale=cbrt:s=640x518[ss]; \
 [0:a]showwaves=s=1280x202:mode=line[sw]; \
 [vs][ss]overlay=w[bg]; \
 [bg][sw]overlay=0:H-h,drawtext=fontfile=/usr/share/fonts/TTF/Vera.ttf:fontcolor=white:x=10:y=10:text='\"Song Title\" by Artist'[out]" \
-map "[out]" -map 0:a -c:v libx264 -preset fast -crf 18 -c:a copy output.mkv

From How to Encode Videos for YouTube and other Video Sharing Sites.

  • Hmmm, unfortunately neither of the pipe-to-wav2png options are working. wav2png produces a blank image with only a uniform background color and no waveform. Nice visuals though! – curtisdf Sep 21 '14 at 15:01

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.