vapoursynth / subtext

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

TextFile + RGB: MaskedMerge: Input frames must have the same range #13

Closed Selur closed 1 year ago

Selur commented 1 year ago

When using:

# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SubtitleFilter/SubText/SubText.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libimwri.dll")
# source: 'G:/clips/scrolling_subs/croquants.png'
# current color space: RGB24, bit depth: 8, resolution: 720x480, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading G:\clips\scrolling_subs\croquants.png using vsImageReader
clip = core.imwri.Read(["G:/clips/scrolling_subs/croquants.png"])
clip = core.std.Loop(clip=clip, times=6050)
# Input color space is assumed to be RGB24
# Setting color transfer info (470bg), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
# Setting color primaries info (), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
# Loading G:\clips\scrolling_subs\hector.ass using SubText
clip = core.sub.TextFile(clip=clip, file="G:/clips/scrolling_subs/hector.ass", fontdir="F:/Hybridnew/settings/fonts")
# adjusting output color from: RGB24 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited")
# set output frame rate to 25fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()

I get:

Error: Failed to retrieve frame 0 with error: MaskedMerge: Input frames must have the same range

script works fine if I convert to YUV420P8 before the call of 'core.sub.TextFile' or if I remove the 'core.sub.TextFile' call.

myrsloik commented 1 year ago

Can you print all the frame properties of the input or create a blankclip only reproduction case? That'd make this much easier to debug since now I have to guess what imwri outputs.

Selur commented 1 year ago

Attached the used .png- and .ass-file, this should allow you to reproduce the issue (after adjusting paths) with the script I posted. scrolling_subs.zip

myrsloik commented 1 year ago

What you're doing is complete nonsense. You get RGB24 back (which the picture is, I verified) and then you stuff YUV(!!!!!!) primaries on it and set it to limited range. Those things have no support in reality. MaskedMerge then gets the limited range rgb (input image) and the full range rgb (subtitle image) to combine which is not possible. Limited range RGB is insanity!