Vapoursynth Add Logo

From wiki.selur.net
Jump to navigation Jump to search

Add Logo lays an image, usually a PNG with transparency, over the video at a given position, optionally only for a range of frames.

Filtering → Vapoursynth → Other

Add Logo controls in Hybrid
Add Logo controls in Hybrid

What it does

The logo is placed with its top-left corner at the given position; parts outside the frame are cut off. Its alpha channel decides how opaque each pixel is (darker = more transparent); the alpha can be ignored (fully opaque logo) or inverted.

Requirements

  • BestSource (reads the image) and fmtconv; both ship with Hybrid. Works on all platforms.

Settings

Control Parameter Range / values Hybrid default Meaning
Logo / Select – image file empty Image to lay over the video; empty = filter skipped.
Position (x/y) x, y −8192 – 8192 0 / 0 Top-left corner of the logo in pixels; negative values move it partly out of the frame to the left or top.
From – To – 0 – last frame 0 / 0 First and last frame (inclusive) that get the logo; 0 / 0 = whole clip, To = 0 = till the end.
No alpha – on/off off The logo image has no alpha channel: no mask is used.
Ignore alpha – on/off off The alpha channel is not used; the logo is fully opaque.
Invert alpha channel – on/off off Inverts the alpha channel; only when neither No alpha nor Ignore alpha is set.

Example

Logo J:/tmp/claude/wiki/assets/logo.png (96x32 PNG with alpha; no logo is set by default), otherwise default settings, on a 10-bit YUV 4:2:0 source (640x356):

# adding logo
# adding 'J:\tmp\claude\wiki\assets\logo.png' using Overlay
logo = core.bs.VideoSource(source="J:/tmp/claude/wiki/assets/logo.png")
alpha = core.std.PropToClip(logo) if "_Alpha" in logo.get_frame(0).props else None
logo = core.resize.Bicubic(clip=logo, format=clip.format.id, matrix_s="470bg", range_s="limited")
alpha = None if alpha is None else core.fmtc.bitdepth(clip=alpha, bits=clip.format.bits_per_sample, fulls=True, fulld=True)
clip = misc.Overlay(base=clip, overlay=logo, mask=alpha)

How Hybrid calls it

  • The image is read with BestSource; a video file works too (its last frame repeats). An image without an alpha channel is laid over without a mask, even if No alpha is not set.
  • The logo is converted to the clip's format, matrix and range; the alpha channel is brought to the clip's bit depth as full range, so semi-transparent areas keep their opacity.
  • The overlay uses a normal blend. Odd positions are fine; with subsampled YUV and an odd logo width or height the clip is converted to 4:4:4 first.
  • With a frame range the clip is split before and after the range and spliced back together.
  • By default Add Logo is the last filter in the chain.
  • Add Logo also offers ApplyOnlyTo from the common options.

Background

Overlay

The overlay function comes from Hybrid's script collection and is derived from havsfunc's Overlay. Like AviSynth's Overlay it accepts negative positions and a mask of the same size as the overlay, and it offers many blend modes and an opacity; Add Logo uses the normal mode at full opacity.

Sources