View Full Version : Textsub 16bit (or equivalent)?
FranceBB
10th May 2017, 12:14
Hi,
I've been playing with 16bit for a while and I'm wondering whether there's a subtitles render (like Textsub) which is able to work at 16bit. Although Dither Tool is still considered an "hack", it would be pretty useful to have a subtitles render which is able to work at 16/12/10bit, in order to output from Avisynth directly in 10bit, instead of dithering up to 16bit, processing everything at 16bit (debanding, denoise etc), dithering down to 8bit and outputting an 8bit video to your favorite codec.
I would really like to avoid this: https://pastebin.com/5f7Njb3Y
Izuchi
11th May 2017, 17:15
http://nmm.me/109
Motenai Yoda
11th May 2017, 23:52
as showed in the docs, you can ditherdown to 8bit, apply an 8bit filter, then convert to 16bit and re-add back the lsb part avoiding pixels who changed too much
s16 = last
DitherPost (mode=-1)
# Insert 8-bit filters here
Dither_convert_8_to_16 ()
s16.Dither_limit_dif16 (last, thr=1.0, elast=2.0)
FranceBB
11th May 2017, 23:57
video=FFVideoSource("test1.mkv", fpsnum=24000, fpsden=1001)
audio=FFAudioSource("test1.mka")
AudioDub(video, audio)
Dither_convert_8_to_16()
ly = debicubic(1280,720,lsb_inout=true)
lu = utoy().dither_resize16(1280,720,kernel="spline16",invks=true,invkstaps=3,src_left=0.25,u=1,v=1)
lv = vtoy().dither_resize16(1280,720,kernel="spline16",invks=true,invkstaps=3,src_left=0.25,u=1,v=1)
ytouv(lu,lv,ly)
#RKS()
f3kdb(range=15, Y=80, Cb=60, Cr=60, grainY=0, grainC=0, keep_tv_range=True, input_depth=16, output_depth=16)
TextSub16("test1.ass")
#Dither_Out()
DitherPost()
Avisynth error:
mt_logic : wrong colorspace, only YUV planar colorspaces are allowed
(TextSub16 v1.1.avsi, line 38)
as showed in the docs, you can ditherdown to 8bit, apply an 8bit filter, then convert to 16bit and re-add back the lsb part avoiding pixels who changed too much
s16 = last
DitherPost (mode=-1)
# Insert 8-bit filters here
Dither_convert_8_to_16 ()
s16.Dither_limit_dif16 (last, thr=1.0, elast=2.0)
Got it.
raffriff42
13th May 2017, 17:26
Here is TextSubPlus, similar in function to TextSub16 (http://nmm.me/109) (post #2) but using AvisynthPlus.
Input & output is in RGB, in 8, 10, 12, 14 or 16-bit. Stack16 is not supported.
It does away with TextSub16's YUV<>RGB and tv-range conversions; those are best handled by the caller.
The result is a much simpler script.
EDIT usage:LoadPlugin(...) ## VSFilter, VSFilterMod, xyVSFilter
#Source(...)
## If source is Stack16, de-stack it:
#ConvertFromStacked
### RGB required
ConvertToPlanarRGBA(matrix="Rec709")
TextSubPlus("<subtitles>") ## for TextSub or xyVSFilter (VSFilter.dll)
#TextSubPlus("<subtitles>", submod=true) ## for TextSubMod (VSFilterMod.dll)
## convert back to YUV if desired
#ConvertToYUV420(matrix="Rec709")
## re-stack if desired
#ConvertToStacked
# https://forum.doom9.org/showthread.php?p=1806888#post1806888
#######################################
### TextSub/TextSubMod over deep color video; requires AviSynthPlus
##
## @ C - source clip. RGB 8, 10, 12, 14, 16-bit.
## @ path - subtitle file: *.sub, *.srt, *.ssa, *.ass, etc. (see TextSub docs)
## @ charset - see TextSub docs
## @ fps - '' '' ''
## @ vfr - '' '' ''
## @ submod - if true, call 'TextSubMod', else (default) call 'TextSub'
## @ edgetrim - if true, shrink & soften the edges of the subtitle mask;
## use this if you see artifacts around the edges of the text
## (not likely to occur; only seen in extreme testing)
## requires MaskTools2 v2.2.x
##
## version 1.0 raffriff42 May 2017
## version 1.0.1 add "vfr" argument, rename "mod"->"submod"
##
function TextSubPlus(clip C, string path, int "charset", float "fps", string "vfr",
\ bool "submod", bool "edgetrim")
{
Assert(C.IsRGB,
\ "TextSubPlus: source must be RGB")
submod = Default(submod, false)
edgetrim = Default(edgetrim, false)
bits = C.BitsPerComponent
c8 = (bits==8)
\ ? C.ConvertToRGB32
\ : C.ConvertBits(8).ConvertToRGB32
#@ function TextSub(clip C, string "file", int "charset", float "fps", string "vfr")
c8sub = (submod)
\ ? c8.TextSubMod(path, charset, fps, vfr)
\ : c8.TextSub(path, charset, fps, vfr)
csub = (bits==8)
\ ? c8sub
\ : c8sub.ConvertToPlanarRGBA.ConvertBits(bits)
M = csub.ExtractA.Invert
M = (edgetrim) ? Eval("M.mt_inpand") : M
return (bits==8)
\ ? c8sub
\ : Overlay(C, csub, mask=M)
}
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.