Configure FFmpeg Oscilloscope Position, Channel, and Size

This article demonstrates how to customize the visual representation of audio using the aoscilloscope filter in FFmpeg. You will learn how to adjust the output window size, select specific audio channels for display, and position both the oscilloscope waves inside the canvas and the visualizer itself over a background video.

Adjusting the Canvas Size

To change the dimensions of the oscilloscope visualization, use the size (or s) parameter. This defines the width and height of the generated video stream. By default, FFmpeg outputs a 720p (1280x720) canvas.

To set a custom resolution, such as 800x600, use the following syntax:

ffmpeg -i input.mp3 -filter_complex "aoscilloscope=s=800x600" output.mp4

Selecting Audio Channels

To control which audio channels are displayed, use the components (or c) parameter. This parameter uses a bitmask value to enable or disable specific channels.

For example, to display only the left channel on the oscilloscope:

ffmpeg -i input.mp3 -filter_complex "aoscilloscope=c=1" output.mp4

Positioning the Oscilloscope

Positioning can be handled in two ways: moving the waveforms inside the oscilloscope canvas, or placing the entire oscilloscope screen over an existing background video.

1. Internal Position (X and Y Coordinates)

You can change the center point of the waveform display within its canvas using the x and y parameters. These values are written as relative floats between 0 and 1.

For example, to center the waves precisely:

ffmpeg -i input.mp3 -filter_complex "aoscilloscope=x=0.5:y=0.5" output.mp4

2. External Position (Overlaying on Video)

If you want to position the oscilloscope at a specific coordinate over a background video, use the overlay filter.

The command below generates a 400x300 oscilloscope from the audio track and overlays it on a background video at coordinates X=50 and Y=50:

ffmpeg -i background.mp4 -i input.mp3 -filter_complex "[1:a]aoscilloscope=s=400x300:c=3[scope];[0:v][scope]overlay=x=50:y=50[outv]" -map "[outv]" -map 1:a -short output.mp4