Last active
January 23, 2024 21:27
-
-
Save cN3rd/4825bb753680b9e9f67e938f7cd5b4bd to your computer and use it in GitHub Desktop.
Modified Typositter for Avisynth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original script by nicoco, under GPLv2 | |
# Modified typositter. Currently only boasts support for custom conversion matrices. | |
function TypositterMod(clip source, clip type, int start_frame, int "end_frame", int "x", int "y", bool "trim", string "mode", float "opacity", string "matrix", bool "debug") { | |
Assert((FrameCount(type) != 1001 || Defined(end_frame)), "For this footage, the ending frame is needed.") | |
end_frame = Default(end_frame, start_frame + FrameCount(type) - 1) | |
trim = Default(trim, false) | |
opacity = Default(opacity, 1.0) | |
mode = Default(mode, "blend") | |
x = Default(x, 0) | |
y = Default(y, 0) | |
debug = Default(debug, False) | |
matrix = Default(matrix, "rec709") | |
# do color conversion | |
#load type and overlay on selected frames on the video | |
type_mask = type.ShowAlpha(pixel_type=source.PixelType()) | |
type = type.ConvertToYV24(matrix=matrix) | |
type = Overlay(source.trim(start_frame, end_frame), mask=type_mask, type, x=x, y=y, mode=mode,opacity=opacity) | |
type = debug ? type.Subtitle(String(start_frame)+","+String(end_frame), x=8, y=0, first_frame=0, font="Arial", size=50, text_color=$FFFF00) : type | |
#check if trim is set to false, if it is then return trimmed type. | |
#else check if type is timed to the start and\or the end of the video, and add the missing parts of the video | |
trim ? Eval(""" | |
source = type | |
""") : Eval(""" | |
source_start = start_frame <= 0 ? type : source.trim(0, start_frame-1) ++ type | |
source = end_frame >= source.framecount() ? source_start : source_start ++ source.trim(end_frame+1, 0) | |
""") | |
return source | |
} | |
# Compatibility layer around existing typositter | |
function Typositter(clip source, clip type, int start_frame, int "end_frame", int "x", int "y", bool "trim", string "mode", float "opacity", bool "debug" ,bool "hdcolor") { | |
hdcolor = Default(hdcolor, False) | |
matrix = hdcolor ? "rec709" : "rec601" | |
TypositterMod(source, type, start_frame, end_frame, x, y, trim, mode, opacity, debug, matrix) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment