Log in

View Full Version : Problem with .sup subtitles,...


Selur
4th June 2019, 19:26
# Imports
import vapoursynth as vs
core = vs.get_core()
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# Loading F:\Test,mkvv using LWLibavSource
clip = core.lsmas.LWLibavSource(source="F:/Test,mkv", format="YUV420P8", cache=0)
# making sure input color matrix is set as 709
clip = core.resize.Point(clip, matrix_in_s="709",range_s="limited")
# making sure frame rate is set to 24000/1001
clip = core.std.AssumeFPS(clip, fpsnum=24000, fpsden=1001)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# Loading image based subtitle F:\TestClips&Co\files\Subtitles\00010.track_4608.sup using Subtitle
def rgba(r, g, b, a=255):
if r < 0 or r > 255 or g < 0 or g > 255 or b < 0 or b > 255 or a < 0 or a > 255:
raise vs.Error("Colours must be in the range [0, 255].")

return (a << 24) + (r << 16) + (g << 8) + b

unused = 1 << 42
subs = core.sub.ImageFile(clip=clip, file="F:/TestClips&Co/files/Subtitles/00010.track_4608.sup", palette=[rgba(0, 0, 0), rgba(255, 255, 255), rgba(0, 0, 0), rgba(0, 0, 0)])
alpha = core.std.PropToClip(subs)
subs = core.resize.Bicubic(subs, width=clip.width, height=clip.height, format=clip.format.id, matrix_s="709", matrix_in_s="709", range_s="limited")
gray_format = core.register_format(vs.GRAY, clip.format.sample_type, clip.format.bits_per_sample, 0, 0)
alpha = core.resize.Bicubic(alpha, width=clip.width, height=clip.height, format=gray_format.id, range_s="limited")
clip = core.std.MaskedMerge(clip, subs, alpha)
# adjusting output color from: RGB24 to YUV420P8 for x264Model (i420)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="709", range_s="limited")
# Output
clip.set_output()
gives me:
Failed to evaluate the script:
Python exception: PropToClip: no frame stored in property

Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 1927, in vapoursynth.vpy_evaluateScript
File "src\cython\vapoursynth.pyx", line 1928, in vapoursynth.vpy_evaluateScript
File "E:\Temp\tempPreviewVapoursynthFile20_15_41_474.vpy", line 23, in <module>
alpha = core.std.PropToClip(subs)
File "src\cython\vapoursynth.pyx", line 1833, in vapoursynth.Function.__call__
vapoursynth.Error: PropToClip: no frame stored in property
I thought I used the same script with different subtitles before and didn't have the issue. (think I got the base script from https://forum.doom9.org/showthread.php?t=173748 nearly 3 years ago, did I miss some changes?)

Cu Selur

jackoneill
5th June 2019, 12:46
I think I will need the sup file to debug this.

Selur
6th June 2019, 15:48
Send you a link to two subtitle files from different sources.

When using:
subs = core.sub.ImageFile(clip=clip, file="C:/Users/Selur/Desktop/Aquaman.sup", palette=[rgba(0, 0, 0), rgba(255, 255, 255), rgba(0, 0, 0), rgba(0, 0, 0)], blend=False)
alpha = core.std.PropToClip(subs)
subs = core.resize.Bicubic(subs, width=clip.width, height=clip.height, format=clip.format.id, matrix_s="709", range_s="limited")
it seems to work, so from the looks of it, this is somehow related to the 'blend' option.

Cu Selur

jackoneill
6th June 2019, 19:00
from the looks of it, this is somehow related to the 'blend' option.

Cu Selur

I didn't notice your script didn't have blend=False. Yes, if you want to do your own blending, you have to pass blend=False. Mystery solved, no need for any samples after all.

Selur
7th June 2019, 19:03
Okay, can you give an example with blend=True ? I can't get the syntax right from the looks of it.

jackoneill
8th June 2019, 11:36
Okay, can you give an example with blend=True ? I can't get the syntax right from the looks of it.


clip = core.lsmas.LWLibavSource(source="F:/Test,mkv", format="YUV420P8", cache=0)

clip = core.sub.ImageFile(clip=clip, file="C:/Users/Selur/Desktop/Aquaman.sup", palette=[rgba(0, 0, 0), rgba(255, 255, 255), rgba(0, 0, 0), rgba(0, 0, 0)])


That's it. You get your video with subtitles on it.

Selur
9th June 2019, 07:30
Ah, okay. Thanks! :)