Utilities.avsi — Various Utility Functions

Miscellaneous utilities that I’ve found somewhat useful.

AudioToClip(audio, fps=24.0)
Parameters:
  • audio (clip) – the audio clip to be turned into a clip
  • fps (float) – the FPS of the returned clip (defaults to 24)

AudioDub an audio clip on a BlankClip to allow it to be trimmed.

VideoLengthToAudioLength(c)
Parameters:c (clip) – the clip to match audio and video lengths

Adds/removes frames from the video to match the audio length (via ChangeFPS).

Cut(c, start, end)
Parameters:
  • c (clip) – the clip to cut
  • start (int) – the first frame (inclusive) to be removed
  • end (int) – the last frame (exclusive) to be removed

Cut out a region of frames.

DissolveCut(c, start, end[, overlap])
Parameters:
  • c (clip) – the clip to cut
  • start (int) – the first frame (inclusive) to be removed (fade starts on this frame)
  • end (int) – the last frame (exclusive) to be removed (fade back in ends on this frame)
  • overlap (int) – if given, the number of frames over which to fade while dissolving between the cut areas. Defaults to 1 second by rounding the frame rate to the nearest whole number.

Cut out a region, dissolving over the start and end of the cut footage. This actually removes the region from start + overlap through end - overlap. So DissolveCut(c, 400, 600, 30) will completely remove frames 430-570 (inclusive), and frames 400-429 will dissolve to frames 571-600.

LayerFadeIO(back, over, start, end, start_time, [end_time, ]x=0, y=0, easing="linear"[, end_easing])
Parameters:
  • back (clip) – the clip to fade on top of
  • over (clip) – the clip being faded on top of back
  • start (int) – the frame to start fading in on
  • end (int) – the frame to have finished fading out on
  • start_time (int) – the number of frames to fade in over
  • end_time (int) – the number of frames to fade out, defaults to start_time
  • x, y (int) – coordinates to place the upper layer on; defaults to 0,0
  • easing (string) – the easing function to use; defaults to EaseInLinear
  • end_easing (string) – the end easing function to use; defaults to the same as easing

Fade a layer on top of another layer. The fade animation starts at the start frame (the first frame where the overlaid clip will be at all visible), and ends at end frame (the last frame where the overlaid clip will be at all visible). The clip will be fully opaque start_time frames after start (so if start is 30 and start_time is 15, the first fully opaque frame will be 45).

Note that in order to use the Easing functions, you must include the Easings.avsi file.

LayerFadeIn(back, over, start, end, start_time, [end_time, ]x=0, y=0, easing="linear"[, end_easing])
Parameters:
  • back (clip) – the clip to fade on top of
  • over (clip) – the clip being faded on top of back
  • start (int) – the frame to start fading in on
  • fade_duration (int) – the number of frames to fade in over
  • x, y (int) – coordinates to place the upper layer on; defaults to 0,0
  • easing (string) – the easing function to use; defaults to EaseInLinear

Fade in a layer on top of another layer. The fade in animation starts at the start frame (the first frame where the overlaid clip will be at all visible) and lasts for fade_duration frames. Once the layer had been faded in, it will remain for the remainder of the video.

Note that in order to use the Easing functions, you must include the Easings.avsi file.

AssertEquals(expected, actual)
Parameters:
  • expected (val) – the expected value
  • actual (val) – the actual value received

Helper function for Assert to provide useful information.

AssertFrameCountEquals(expected, actual[, verb][, message])
Parameters:
  • expected (val) – the base clip with the expected number of frames, or just an integer with the number of frames expected
  • actual (val) – the actual clip with the number of frames to test, or just an integer with the actual number of frames
  • verb (string) – if given, a verb to use in the default message, defaults to “generated”
  • message (string) – if given, a default message to use (the verb parameter is not used in this case)

Fade in a layer on top of another layer. The fade in animation starts at the start frame (the first frame where the overlaid clip will be at all visible) and lasts for fade_duration frames. Once the layer had been faded in, it will remain for the remainder of the video.

Note that in order to use the Easing functions, you must include the Easings.avsi file.