vapoursynth / subtext

Subtitle plugin for VapourSynth based on libass
MIT License
16 stars 5 forks source link

Set alignment of Subtitle? #14

Closed jessielw closed 8 months ago

jessielw commented 8 months ago
import vapoursynth as vs 
core = vs.core
core.std.LoadPlugin(r"img_plugins\SubText.dll")
dummy_clip = core.std.BlankClip(width=600, height=600, fpsnum=24000, fpsden=1001)
sub = core.sub.Subtitle(clip=dummy_clip, blend=False, text="Reference")
print(sub.width)

The end goal is to be able to properly position the text to the right and allow dynamic text resizing based on input. However, it seems like ASS alignment methods do not work for as it want the width of the video.

jessielw commented 8 months ago

Ignore this, can easily be aligned with the style. If anyone else comes across this you can utilize the alignment part of the style

"Font Name, Font Size, Primary Color, Secondary Color, Outline Color, Back Color, Bold, Italic, Underline, Strikeout, Scale X, Scale Y, Spacing, Angle, Border Style, Outline Width, Shadow Depth, Alignment, Left Margin, Right Margin, Vertical Margin, Encoding"
clip = core.sub.Subtitle(
    clip,
    text="Hellooooo! Testing this very very very long line\nWith a break",
    style="sans-serif,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,0,8,9,10,10,1"
)

Setting alignment to 9 sets it to the top right. Can find other alignments here. https://fileformats.fandom.com/wiki/SubStation_Alpha#Fields