FFmpeg Showwaves: Set Dimensions and Draw Mode

The showwaves filter in FFmpeg converts an incoming audio stream into a visual waveform video, which is commonly used to generate video visuals from music or podcast tracks. This guide explains how to customize the visual output by configuring the output dimensions (resolution) and selecting different drawing modes to change how the waveform graph is rendered.

Setting the Output Dimensions

By default, the showwaves filter outputs video at a resolution of 600x240 pixels. You can change this using the size (or s) parameter. The parameter accepts standard resolution abbreviations (such as hd720 or hd1080) or an explicit WIDTHxHEIGHT format.

To set a custom width and height:

ffmpeg -i input.mp3 -filter_complex "[0:a]showwaves=s=1920x1080[v]" -map "[v]" -map 0:a -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4

Using a resolution shorthand:

ffmpeg -i input.mp3 -filter_complex "[0:a]showwaves=s=hd720[v]" -map "[v]" -map 0:a -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4

Configuring the Drawing Mode

The mode parameter defines how sample values are rendered visually on the screen. The showwaves filter supports four drawing modes:

  • point: Renders a single pixel/point for each audio sample.
  • line: Draws a vertical line from the zero-amplitude center line to the sample value (this is the default mode).
  • p2p (point-to-point): Draws continuous vertical lines connecting the minimum and maximum sample points across the frame, creating a fuller, traditional waveform look.
  • cline: Draws centered vertical lines symmetrical around the horizontal axis.

To set a specific drawing mode, assign the mode name to the mode option:

ffmpeg -i input.mp3 -filter_complex "[0:a]showwaves=mode=p2p[v]" -map "[v]" -map 0:a -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4

Combining Dimensions and Drawing Mode

You can combine multiple parameters in the filter string by separating them with colons (:).

The following command generates a 1080p video (1920x1080) using the p2p drawing mode:

ffmpeg -i input.mp3 -filter_complex "[0:a]showwaves=s=1920x1080:mode=p2p:rate=25[v]" -map "[v]" -map 0:a -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4

In this command:

  • s=1920x1080 establishes the video canvas resolution.
  • mode=p2p instructs the filter to draw peak-to-peak continuous vertical lines.
  • rate=25 sets the output video frame rate to 25 frames per second.
  • -pix_fmt yuv420p ensures maximum compatibility with standard media players.