From Avisynth wiki
Jump to: navigation, search
Author Richard Ling, sh0dan
Version 20040318
Category Audio filters
License GPLv2
Discussion Doom9 Thread



This filter displays the audio waveform for a video, superimposed on the video. It is mainly intended to help during editing rather than for final output. It can be useful for finding and isolating specific sequences of dialogue or sound, and for checking that overdubbed audio (especially speech) is in sync with video.

The audio is displayed as a green waveform stretching from left to right across the frame. The filter can graph the audio for the currently visible frame only; or it can include the audio for several successive frames on either side of the current frame. Graphing several frames makes it easier to find a sound of interest. It is also really cool to watch the waveform scrolling across the video as the video plays :-).


Syntax and Parameters

AudioGraph (clip, int)

clip   =
The source clip. YUY2, RGB24 or RGB32 video, with 8-bit or 16-bit mono or stereo audio.

int   =
frames_either_side: The number of frames, either side of the current frame, which should be graphed.
The effect of the frames_either_side parameter is perhaps better explained by this table:
value effect:
  • 0 : only audio for the currently visible frame is graphed.
  • 1 : audio for the preceding, current, and following frames are graphed.
  • 2 : audio for the preceding 2 frames, current frame, and following 2 frames are graphed.
  • ...and so on.
The current frame's audio is displayed in the centre of the video frame in bright green, while audio for preceding and following frames is displayed in darker green.

How this filter works:

An "audioframe" is the audio data corresponding to a video frame, converted into an internal form that can be quickly drawn. A total of (1 + 2 * frames_either_side) audioframes are drawn onto each video frame. Each audioframe is thus (video frame width) / (1 + 2 * frames_either_side) pixels wide. An audioframe simply consists of a Y pixel coordinate for each X pixel coordinate, so drawing an audioframe is very fast.

When frames_either_side is nonzero, the same audioframe will be drawn several times on several successive video frames. So it makes sense to cache audioframes. The filter uses a cache of "audioframe buffers" to store recently used audioframes. Audioframes are generated from raw audio data on demand, and stored in the cache. The caching system is such that a specific audioframe is only ever cached in a specific audioframe buffer, so that cache lookup is very fast. This caching also improves performance when seeking back and forth in a video.

  • The included source code is very well documented, check it out for full details!


The following script creates a video from just an audio file. The video length is automatically adjusted based on the duration of the audio and the desired frame rate. The output clip will be RGB32, 512x256, 59.94 FPS, and frames_either_side=5, of course this is all adjustable.

WavSource("sample.wav") # for other types of files you can use FFAudioSource or LWLibavAudioSource or any other suitable audio source filter
audio = last
fps = 60000 den = 1001 length = Round((AudioDuration(audio)*fps)/den) BlankClip(length, width=512, height=256, fps=fps, fps_denominator=den, pixel_type="RGB32", color=$000000) AudioDub(last, audio)
AudioGraph(5) # frames_either_side - change to desired value


Version       Date            Changes
20040318 03/18/2004 - AviSynth 2.5 version by Sh0dan - No YV12 support. - Should support multiple channels. - YUY2 mode made a bit more eyepleasing, IMO. - - It makes the graph a bit more blocky. - - YUY2 mode is converted to greyscale.
20030808 08/08/2003 - initial release; AviSynth 2.0 plugin by Richard Ling

Archived Downloads

Version Download Mirror Mirror 2


  • Allow the colour of the graph to be passed as a parameter.
  • Allow separate graphing of left or right channels of stereo audio (using different colours).
  • Allow a vertical scale factor to be passed as a parameter, so that quiet waveforms can be seen in more detail.
  • Fix the "feature" that the current frame's audio is not always centered on the display. It can be offset quite far to the right, depending on the relationship between video frame width and frames_either_side.

External Links

Back to External Filters

Personal tools