Log in

View Full Version : Vapoursynth


Pages : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 [61] 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Selur
18th April 2018, 16:49
I have 16gb of ram.
+
with core.max_cache_size = 32768
this seems strange,...

Boulder
19th April 2018, 17:24
I did some tests on a Blu-ray source with my usual script to denoise and downsize to 720p, 2000 frames from the middle:

v44-test1, cache 32768:
Large pages - 10,74 fps
No large pages - 11,06 fps

v43
cache 32768 - 11,02 fps
default cache - 10,02 fps

So no use for me, but the cache size needs to be increased - so thanks for that tip :) I have 16 GB of memory and an AMD Ryzen 1800X system.

Selur
21st April 2018, 08:10
Still a bit confused about max_cache_size.

max_cache_size

Set the upper framebuffer cache size after which memory is aggressively freed. The value is in megabytes.

set_max_cache_size(mb)

Deprecated, use max_cache_size instead.

so since max cache size is in MB and you have 16GB why set it to 32768 = 32GB, shouldn't your 16GB (- normal system memory usage) of RAM be the largest value one should set and not twice the available RAM or am I missing something?

foxyshadis
25th April 2018, 16:34
Still a bit confused about max_cache_size.

so since max cache size is in MB and you have 16GB why set it to 32768 = 32GB, shouldn't your 16GB (- normal system memory usage) of RAM be the largest value one should set and not twice the available RAM or am I missing something?

It's a workaround for large pages in the current version only. If you aren't interested in large pages right now, or you're worried about a filter sucking up all of the cache, don't touch it.

DJATOM
25th April 2018, 16:52
I found a bug. Well, not sure if that's really a bug, but might be unwanted behaviour of resizer.
Nowadays almost all anime blu-rays are upscales. I'd like to fight such upscales downscaling to original resolution using the mixed Descale and Spline36 clip, upscale back with eedi3 and merge it with source clip using lines mask.
Today my friend noticed slight shift in the source/AA comparisons. I tried to debug my script and found that resizer is just copying clip instead of fixing eedi3 shift. In that case 1920x1080 clip was downscaled to 960x540 and upscaled back (so we got 1920x1080 after eedi3 stuff).
As I understand, vapoursynth (zimg) resizer is just copying clip if input width and height matches with output. That might be unwanted if cropping options is set.
On my opinion resizer should check for crop options and do proper resizing in that case.

Selur
25th April 2018, 17:43
@foxyshadis: I get what max_cache_size is meant to do, what I don't get is why setting it to two times your RAM size is the right thing.

Boulder
25th April 2018, 18:25
@foxyshadis: I get what max_cache_size is meant to do, what I don't get is why setting it to two times your RAM size is the right thing.

It's really not. It can easily eat all the RAM you have when the script is initialized and it takes quite a lot of time for VS to release the excess memory so your computer is pretty much frozen. I've settled down for 10240 on my 16 GB system as I can just manage that with BD to 720p encodes.

DJATOM
26th April 2018, 10:00
You probably need to provide an script to demonstrate what you really do, if you want the developers to resolve your doubts.

Okay. Script below is just stripped version to reproduce my problem.

import havsfunc as haf
import mvsfunc as mvf
import descale as dsc

clip = <some 1920x1080 clip>

descale_str = 0.32
kernel = 'bicubic'
descale_h = 540 # 1080/2 to reproduce the problem

w = clip.width
h = clip.height
descale_w = haf.m4((w * descale_h) / h)
descale_natural = dsc.Descale(clip, descale_w, descale_h, kernel=kernel)
descale_aa = core.resize.Spline36(clip, descale_w, descale_h)
descaled = core.std.Merge(clipb=descale_natural, clipa=descale_aa, weight=descale_str)

dx = w
dy = h
ux = descale_w * 2
uy = descale_h * 2
rescale = core.eedi3m.EEDI3(descaled, field=1, dh=True, alpha=0.2, beta=0.25, gamma=1000.0, vcheck=3, sclip=core.znedi3.nnedi3(descaled, field=1, dh=True, nsize=0, nns=4, pscrn=1))
rescale = core.std.Transpose(clip=rescale)
rescale = core.eedi3m.EEDI3(rescale, field=1, dh=True, alpha=0.2, beta=0.25, gamma=1000.0, vcheck=3, sclip=core.znedi3.nnedi3(rescale, field=1, dh=True, nsize=0, nns=4, pscrn=1))
rescale = core.std.Transpose(clip=rescale)
#rescale = core.fmtc.resample(rescale, dx, dy, -0.5, -0.5, ux, uy, kernel='spline36').fmtc.bitdepth(bits=8) # always fixes eedi3 shift, but I need to call bitdepth function, that's not convenient.
rescale = core.resize.Spline36(rescale, dx, dy, src_left=-0.5, src_top=-0.5, src_width=ux, src_height=uy) # leaves eedi3 shift untouched if rescale clip's width and height matches the source.

ChaosKing
26th April 2018, 11:16
You could also use edi_rpow2.py https://gist.github.com/YamashitaRen/020c497524e794779d9c (or just copy the shifting code)

DJATOM
26th April 2018, 11:50
You could also use edi_rpow2.py https://gist.github.com/YamashitaRen/020c497524e794779d9c (or just copy the shifting code)

zimg way is most likely broken, I didn't checked.
Y=core.std.ShufflePlanes(clips=clip, planes=0, colorfamily=vs.GRAY)
Y=core.resize.Spline36(clip=Y,width=clip.width,height=clip.height,src_left=hshift,src_top=-0.5)
clip.width = Y.width, clip.height = Y.height, so resizer is just copying whole plane without doing the job. Another planes should be fixed if colorspace is not YUV444.

hydra3333
28th April 2018, 02:49
Yay, vapoursynth ffmpeg integration seems to be in its way.

http://ffmpeg.org/pipermail/ffmpeg-devel/2018-April/229137.html

I also hold some hope for "for dummies" vapoursynth library build instructions leading to building of a static ffmpeg.exe (including python libs and any other dependencies) ...

Selur
28th April 2018, 06:57
... leading to building of a static ffmpeg.exe (including python libs and any other dependencies) ...
I highly doubt that will happen, since you would probably need to include a whole Python portable environment (or at least a huge portion of it).
To open .vpy-scripts you at least some sort of a Python (runtime) environment.


Cu Selur

Ps.: To open .avs-scripts you need the avisynth.dll (and dependencies).

hydra3333
28th April 2018, 07:05
Ah. I'd hoped, since youtube-dl manages to do it resulting in a standalone .exe ...

For some, unless maybe it could use vapoursynth portable in the same folder, non-static would be as useful as teats on a bull :)

Selur
28th April 2018, 07:26
Ah. I'd hoped, since youtube-dl manages to do it resulting in a standalone .exe ...
youtube-dl isn't statically compiled it seems to wrap all the dependencies it requires.
Yes once could also wrap a whole hdd this way and create one large binary, but that isn't statically compiling that is basically the same thing Mac does with it's .app files.
(Provide mostly standalone packages which are basically a folder structure which contains dependencies&co.)

Cu Selur

ChaosKing
30th April 2018, 00:36
Is it possible to compare the value of f.props.PlaneStatsAverage in a FrameEval function with the previous and the next frame (n-1 and n+1)? Sould I use get_frame_async() for that?

def g(n, f, clip, d_clip):
clip=clip.text.Text("current: "+ f.props.PlaneStatsAverage)
clip=clip.text.Text("\nPrev: "+ ???)
clip=clip.text.Text("\n\nNext: "+ ???)

return clip
clip = clip.std.FrameEval(functools.partial(g, d_clip=d_clip, clip=clip), prop_src=x)

Edit
This works but feels more like a hack.
x= clip.std.PlaneStats()
x1= clip.std.PlaneStats().std.DuplicateFrames(0) #prev
x2= clip.std.PlaneStats().std.Trim(1) #next

clip = clip.std.FrameEval(functools.partial(g, d_clip=d_clip, clip=clip), prop_src=[x, x1, x2])

amayra
1st May 2018, 22:39
Python development mode
A new command-line switch for the Python interpreter, -X, lets the developer set a number of low-level options for the interpreter. With Python 3.7, the option -X dev enables “development mode,” a slew of runtime checks that normally have a big impact on performance, but are useful for a developer during the debugging process
as vapoursynth user is this benefits me ?

Myrsloik
1st May 2018, 22:44
Is it possible to compare the value of f.props.PlaneStatsAverage in a FrameEval function with the previous and the next frame (n-1 and n+1)? Sould I use get_frame_async() for that?

def g(n, f, clip, d_clip):
clip=clip.text.Text("current: "+ f.props.PlaneStatsAverage)
clip=clip.text.Text("\nPrev: "+ ???)
clip=clip.text.Text("\n\nNext: "+ ???)

return clip
clip = clip.std.FrameEval(functools.partial(g, d_clip=d_clip, clip=clip), prop_src=x)

Edit
This works but feels more like a hack.
x= clip.std.PlaneStats()
x1= clip.std.PlaneStats().std.DuplicateFrames(0) #prev
x2= clip.std.PlaneStats().std.Trim(1) #next

clip = clip.std.FrameEval(functools.partial(g, d_clip=d_clip, clip=clip), prop_src=[x, x1, x2])

That's the right way.

LigH
1st May 2018, 23:03
@ amayra:

Users will probably not benefit directly from debugging switches, because users will usually prefer the fastest possible execution. You may have read that these additional runtime checks will "have a big impact on performance" (see your quote), which means that it will run a lot slower and report a lot of warnings, even of less probable conditions.

But if a developer can use this mode to discover risky code and fix bugs (possibly even before they cause noticeable issues), then users may benefit indirectly from an advanced release build.

ChaosKing
2nd May 2018, 14:16
@Myrsloik
Ok, thx.
I found a strange behaviour while playing with FrameEval func.

The very same function gives different output if it's called within FrameEval.
Is it a bug or did I miss something?
Here's an animated gif of my problem (correct output is in the middle):
https://i.imgur.com/r2pqEj9.gif

And my script (You'll need also Single Precision MVTools https://github.com/IFeelBloated/vapoursynth-mvtools-sf):
import sys
import os

import functools
import vapoursynth as vs

import mvsfunc as mvf #https://github.com/HomeOfVapourSynthEvolution/mvsfunc/blob/master/mvsfunc.py
import havsfunc as haf
import mvmulti as mv #https://github.com/IFeelBloated/vapoursynth-mvtools-sf/blob/master/src/mvmulti.py
import fvsfunc as fvf #https://github.com/Irrational-Encoding-Wizardry/fvsfunc/blob/master/fvsfunc.py

core = vs.get_core()

def myFilter(clip):
pre = haf.SMDegrain(clip, tr=2, pel=2, contrasharp=False, thSAD = 1200, thSADC = 1200, prefilter=2)
pre = pre.flux.SmoothT(temporal_threshold=6)
pre = haf.DitherLumaRebuild(pre, s0=1)
pre = fvf.Depth(pre, 32, range_in=1)

clip = mvf.Depth(clip, 32)

super = core.mvsf.Super(pre,16,16,1,0)
vectors = mv.Analyze(super, blksize=16, overlap=8, search=4, tr=6)
super = core.mvsf.Super(clip,16,16,1,1)
blur_clip = mv.DegrainN(clip, super, vectors, thsad=600, tr=6)

grain = blur_clip.grain.Add(var=1200.0, constant=True)#.std.BoxBlur(hradius=1, hpasses=1, vradius=1, vpasses=1)
#return grain
diff_clip = core.std.Expr([clip, blur_clip], 'x y - abs').std.Inflate(threshold=200/255).std.Inflate(threshold=200/255)
mask_clip = diff_clip.std.Binarize(threshold=[3.3/219, 3.3/224], v0=0, v1=80/255)

clip = core.std.MaskedMerge(clipa=blur_clip, clipb=grain, mask=mask_clip)

return mvf.Depth(clip, 8)



clip = core.std.BlankClip(format=vs.YUV420P8, width=120*2, height=80*2, length=100, color=[206,235,135])
g_static = clip.grain.Add(var=100.0, constant=True)
g_dynamic = clip.grain.Add(var=100.0, constant=False)


clip = core.std.StackHorizontal([
core.std.StackVertical([g_static, g_static]),
core.std.StackVertical([g_static, g_dynamic])
])
goal = core.std.StackHorizontal([
core.std.StackVertical([g_static, g_static]),
core.std.StackVertical([g_static, g_static])
])
orig=clip




def asd(n, c):
return myFilter(c)

feval = clip.std.FrameEval(functools.partial(asd, c=clip))

def comp(a, b, crop=0):
return core.std.StackHorizontal([
core.std.CropRel(a, crop,crop,0,0), \
core.std.CropRel(b, crop,crop,0,0), \
])

nofeval = myFilter(clip)

clip = comp(feval.text.Text("Function inside FrameEval").std.AddBorders(right=2), nofeval.text.Text("No FrameEval").std.AddBorders(right=2), crop=0)
clip = comp(clip, orig.text.Text("unfiltered"), crop=0)

clip.set_output()

Myrsloik
2nd May 2018, 14:22
@Myrsloik
Ok, thx.
I found a strange behaviour while playing with FrameEval func.

The same function gives different output if it's called within FrameEval.
Is it a bug or did I miss something?
Here's a animated gif of my problem (correct output is in the middle):
https://i.imgur.com/r2pqEj9.gif

And my script (You'll need also Single Precision MVTools https://github.com/IFeelBloated/vapoursynth-mvtools-sf):
...

Should be identical in theory, yes. Unless some filter stores temporal state incorrectly. Then you get this. Gradually remove each filter and see when the output is once again identical, then report which filter it was. I'm going to bet mvtools or fluxsmooth right away.

ChaosKing
2nd May 2018, 14:31
Seems it only happens if mvtools-sf is in the filter chain.
Edit:
Is there a way (hack) to avoid this problem without modifying mvtools? I mean except putting it outside of FrameEval, bcs it's very slow and I need it only for many short scenes.

I will report this bug to feisty2 but who knows when and if he's gonna fix it.

ChaosKing
2nd May 2018, 15:39
Generally I don't recommend invoking filters within FrameEval unless unavoidable, because that introduces extra overhead.


from vapoursynth import core
import vapoursynth as vs
import functools

def frame_eval(n, clip):
return core.misc.AverageFrames(clip, weights=[1] * 5)

clip = core.std.BlankClip(width=720, height=480, format=vs.YUV420P8, length=10000)

#clip = core.misc.AverageFrames(clip, weights=[1] * 5)
# I get 1014.60 fps

#clip = core.std.FrameEval(clip, functools.partial(frame_eval, clip=clip))
# I get 566.09 fps

clip.set_output()


You should assign the filtered result to a variable outside FrameEval and then pass it in via functools.partial() as additional argument if possible.

Why didn't I think of that... it works perfectly. :thanks:

ChaosKing
2nd May 2018, 16:45
I get the same speed up ~3x with your script. But what kind of cpu do you have to get 3000fps? My Ryzen 1700 8core @3.6ghz gets only half of that (VS R43)

Myrsloik
5th May 2018, 18:27
R44-test2 (https://www.dropbox.com/s/r2b3pnhfsw452zy/VapourSynth-R44-test2.exe?dl=1)

More large page fixes and updated zimg. Test again because this will probably work better.

WINDOWS 10 APRIL UPDATE IS REQUIRED FOR PROPER LARGE PAGE TESTING

I forgot to mention that the cache logic has been improved so settings max memory usage to yuuuuuge numbers shouldn't be necessary anymore.

ChaosKing
5th May 2018, 23:55
Yep, I get the same speed (64-65fps, 4fps more than test1) with and without core.max_cache_size = 32768, cpu @ 99%, April 1803 update is installed.
With no max_cache set this is shown: Script exceeded memory limit. Consider raising cache size.

Boulder
7th May 2018, 16:31
Did something break with the Windows 10 April 1803 update? I'm unable to load KNLMeansCL anymore; the plugin has been in the plugins64 folder all the time and now VSEdit is saying "AttributeError: No attribute with the name knlm exists. Did you mistype a plugin namespace?"


import vapoursynth as vs
core = vs.get_core()
clp = core.dgdecodenv.DGSource(r'C:\Temp\testclip.dgi')
clp = core.knlm.KNLMeansCL(clp)
clp.set_output()

DJATOM
7th May 2018, 16:39
Check if your video drivers properly installed... Massive updates usually breaks things for me.

Boulder
7th May 2018, 16:41
Check if your video drivers properly installed... Massive updates usually breaks things for me.

Yes, just found out that the stupid update rendered the graphics card useless and the NVIDIA driver package didn't even find an older version from the computer. Because I don't play games with the computer, I never noticed until now.

:sly::mad:

Boulder
7th May 2018, 17:13
With no max_cache set this is shown: Script exceeded memory limit. Consider raising cache size.

I get this message with a 1080p source and some MVTools-based denoising + contrasharpening and advanced downsizing stuff in the script. I've tried setting the cache at 12000 but at some point the warning appears in the encoder log. Of course, with that value being so high (I have 16 GB of memory), the computer ends up swapping a lot so I need to tune it back to 10240 or so.

After some time, the memory usage of the vspipe process goes down to 3-4 GB of memory and stays there until the end. Does it mean that it's actually not useful to set a high value to start the encoding with?

EDIT: Except that with r44t2, the memory usage stays high all the time.

LigH
7th May 2018, 17:39
Side info...

MABS is supposed to be able to build ffmpeg with VapourSynth support (for video filtering, like in mpv, IIRC). But it is important to know: If you build ffmpeg with VS support, VS also becomes a requirement to even start this specific ffmpeg build, it won't run on a PC where VS is not installed.

So I doubt I would provide such a build, as I won't need it for this kind of usage.

Myrsloik
7th May 2018, 20:19
I get this message with a 1080p source and some MVTools-based denoising + contrasharpening and advanced downsizing stuff in the script. I've tried setting the cache at 12000 but at some point the warning appears in the encoder log. Of course, with that value being so high (I have 16 GB of memory), the computer ends up swapping a lot so I need to tune it back to 10240 or so.

After some time, the memory usage of the vspipe process goes down to 3-4 GB of memory and stays there until the end. Does it mean that it's actually not useful to set a high value to start the encoding with?

EDIT: Except that with r44t2, the memory usage stays high all the time.

Basically the logic is closer to Avisynth behavior now. All leftover memory is used for recycled framebuffers. I have some ideas on how to improve things later. I don't think it's ideal but it does improve another corner case a lot... But if it stops at such a low total memory usage you can set it lower to begin with and it won't cause any problems.

Pat357
18th May 2018, 23:46
Side info...

MABS is supposed to be able to build ffmpeg with VapourSynth support (for video filtering, like in mpv, IIRC). But it is important to know: If you build ffmpeg with VS support, VS also becomes a requirement to even start this specific ffmpeg build, it won't run on a PC where VS is not installed.

So I doubt I would provide such a build, as I won't need it for this kind of usage.

Appearently can ffmpeg with --enable vapoursynth be build that it will run also without any VS installed. This is done by building everything as static and load the stuff as delayed import.

The guys here build a binary ffmpeg this way (with gcc) and this version, unlike many other builds (ie the media-suite version) works very well.
The build from media-suite needs indeed that VS is installed, but even then I can't make it output any video from a valid VPY script.

See https://forum.doom9.org/showthread.php?t=175341

LigH
20th May 2018, 15:19
Supporting VS optionally when the environment is available ... that will be much more interesting. :cool:

lansing
21st May 2018, 20:10
I'm wondering can vapoursynth read color value in hex?

foxyshadis
22nd May 2018, 01:14
Color is only ever read as a Python list of each value per plane. There's nothing keeping you from implementing a convenience function, however, like:

def Hex2List(colorhex):
digits = math.ceil(colorhex ** (1/16.))
colorlist = []
for plane in range(0,digits):
colorlist.insert(0, colorhex % 256)
colorhex = colorhex // 256
return colorlist

And calling it as Hex2List(0x778899).

You can always use an actual list like [0x77, 0x88, 0x99], so the value of this convenience is questionable.

lansing
22nd May 2018, 02:32
Color is only ever read as a Python list of each value per plane. There's nothing keeping you from implementing a convenience function, however, like:

def Hex2List(colorhex):
digits = math.ceil(colorhex ** (1/16.))
colorlist = []
for plane in range(0,digits):
colorlist.append(colorhex % 256)
colorhex = colorhex // 256
return colorlist

And calling it as Hex2List(0x778899).

You can always use an actual list like [0x77, 0x88, 0x99], so the value of this convenience is questionable.

I'm talking about things like using it in blankclip like this, instead of the longer rgb value.


clip = core.std.BlankClip(color="#ffffff")

foxyshadis
22nd May 2018, 04:57
I'm talking about things like using it in blankclip like this, instead of the longer rgb value.


clip = core.std.BlankClip(color="#ffffff")


Is BlankClip(color=[0xff, 0xff, 0xff]) that much harder? If it is, use that convenience function in my last post.

lansing
22nd May 2018, 05:23
Is BlankClip(color=[0xff, 0xff, 0xff]) that much harder? If it is, use that convenience function in my last post.

I will need to load in a bunch of color, so the shorter the representation the better.

And Hex2List(0x778899) and [0x77, 0x88, 0x99] give me different color.

foxyshadis
22nd May 2018, 07:15
Whoops, edited. I forgot to test. If you're going to get a lot of use out of it, might as well rename it H2L or something.

lansing
22nd May 2018, 08:43
Thanks foxyshadis and Holy, the function works now

Pat357
25th May 2018, 14:31
Supporting VS optionally when the environment is available ... that will be much more interesting. :cool:

That's exactly what I mean !
See https://forum.doom9.org/showthread.php?p=1840628#post1840628

See here for proof : HolyWu compiled a ffmpeg binary (https://forum.doom9.org/showthread.php?p=1840663#post1840663)

He has also given a way how to create such binary :
https://forum.doom9.org/showthread.php?p=1840703#post1840703

Or read the whole thread (only 2 pages) at
https://forum.doom9.org/showthread.php?t=175341

I hope this makes you reconsider building ffmpeg with --enable-vapoursynth, because it works for all : VS installed, portable VS and without any VS.

Selur
26th May 2018, 11:17
Got a small question, since my Vapoursynth/Python understanding is lacking. :/
I got the following script:
# Imports
import os
import sys
import vapoursynth as vs
core = vs.get_core()
# Import scripts folder
scriptPath = 'G:/Hybrid/64bit/vsscripts'
sys.path.append(os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="G:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
core.std.LoadPlugin(path="G:/Hybrid/64bit/vsfilters/SourceFilter/Imagemagick/libimwri.dll")
# Import scripts
import havsfunc
import mvsfunc
# Loading C:\Users\Selur\Desktop\Image sequence\%02d.png using vsImageReader
clip = core.imwri.Read("C:/Users/Selur/Desktop/Image sequence/%02d.png", firstnum=1)
clip = core.std.Trim(clip=clip, length=30)
# making sure frame rate is set to 25/1
clip = core.std.AssumeFPS(clip, fpsnum=25, fpsden=1)
# Making sure input color range is set to PC (full) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=0)
original = clip
# line darkening using Toon
# adjusting color space from RGB24 to YUV444P16 for VsToon
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709")
clip = havsfunc.Toon(input=clip)
# adjusting output color from: YUV444P16 to YUV420P8 for x264Model (i420)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8)
# adjusting for FilterView; original is RGB24 and clip is YUV420P8
if original.format.id != clip.format.id:
if (original.format.id == vs.RGB24 or original.format.id == vs.RGB32):
original = core.resize.Bicubic(original, format=clip.format.id,matrix_s="709",matrix_in_s="709")
else:
original = core.resize.Bicubic(original, format=clip.format.id,matrix_in_s="709")
clip = core.text.Text(clip,"Filtered")
original = core.text.Text(original,"Original")
interleaved = core.std.Interleave([clip, original])
# Output
interleaved.set_output()
Where I want to apply 'Toon' to the input and compare it to the original, but get:
Error getting the frame number 1:
Resize error 1026: RGB color family cannot have YUV matrix coefficients
I hoped that using the if-block would fix the issue.

-> How to fix this? + Is there a way to check if original.format.id is inside vs.RGB ?

Cu Selur

Myrsloik
26th May 2018, 11:26
Check the color_family property instead. It indicates rgb/yuv/gray. I suspect that's what you want

Selur
26th May 2018, 11:38
What I want is that in case the formats of original and clip differ, that original should be adjusted.
Since converting from RGB to YUV requires that matrix_s is specified I need some 'if'-block.

How to get the frame propery?
original.props['color_family']
doesn't work. :)

Selur
26th May 2018, 11:48
okay it's original.format.color_family.
Problem is:
# Imports
import os
import sys
import vapoursynth as vs
core = vs.get_core()
# Import scripts folder
scriptPath = 'G:/Hybrid/64bit/vsscripts'
sys.path.append(os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="G:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
core.std.LoadPlugin(path="G:/Hybrid/64bit/vsfilters/SourceFilter/Imagemagick/libimwri.dll")
# Import scripts
import havsfunc
import mvsfunc
# Loading C:\Users\Selur\Desktop\Image sequence\%02d.png using vsImageReader
clip = core.imwri.Read("C:/Users/Selur/Desktop/Image sequence/%02d.png", firstnum=1)
clip = core.std.Trim(clip=clip, length=30)
# making sure frame rate is set to 25/1
clip = core.std.AssumeFPS(clip, fpsnum=25, fpsden=1)
# Making sure input color range is set to PC (full) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=0)
original = clip
# line darkening using Toon
# adjusting color space from RGB24 to YUV444P16 for VsToon
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709")
clip = havsfunc.Toon(input=clip)
# adjusting output color from: YUV444P16 to YUV420P8 for x264Model (i420)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8)
# adjusting for FilterView
if original.format.id != clip.format.id:
if (original.format.color_family == vs.RGB and clip.format.color_family != vs.RGB):
original = core.resize.Bicubic(original, format=clip.format.id,matrix_s="709",matrix_in_s="709")
elif (original.format.color_family == clip.format.color_family):
original = core.resize.Bicubic(original, format=clip.format.id)
else:
original = core.resize.Bicubic(original, format=clip.format.id,matrix_in_s="709")
clip = core.text.Text(clip,"Filtered")
original = core.text.Text(original,"Original")
interleaved = core.std.Interleave([clip, original])
# Output
interleaved.set_output()
sill causes the error.
Error getting the frame number 1:
Resize error 1026: RGB color family cannot have YUV matrix coefficients

No clue where the problem is.
I thought this should do the conversion and not add YUV matrix to RGB.

Selur
26th May 2018, 23:37
Thanks a lot ! That helped.
Didn't know about mvsfuncs Preview function.

Cu Selur

unix
30th May 2018, 15:42
Guys i got an error with some scripts

Failed to evaluate the script:
Python exception: (unicode error) 'utf-8' codec can't decode byte 0xe9 in position 35: invalid continuation byte (mvsfunc.py, line 1267)

Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 1847, in vapoursynth.vpy_evaluateScript
File "C:/Users/G_N-A/Desktop/VapourSynthEditor-r16-64bit/Untitled.vpy", line 4, in
File "C:\Users\G_N-A\AppData\Local\Programs\Python\Python36\Lib\fvsfunc.py", line 4, in
import havsfunc as haf # https://github.com/HomeOfVapourSynthEvolution/havsfunc
File "C:\Users\G_N-A\AppData\Local\Programs\Python\Python36\Lib\havsfunc.py", line 2, in
import mvsfunc as mvf
File "C:\Users\G_N-A\AppData\Local\Programs\Python\Python36\Lib\mvsfunc.py", line 1267
"""
^
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe9 in position 35: invalid continuation byte

I have python-3.6.5-64 & VapourSynth-R43-64, and I have attached 3 scripts that showing in the error message.

any help!

lansing
30th May 2018, 15:53
Guys i got an error with some scripts


I have python-3.6.5-64 & VapourSynth-R43-64, and I have attached 3 scripts that showing in the error message.

any help!

You haven't put anything inside the double quotation.

unix
30th May 2018, 17:01
You haven't put anything inside the double quotation.

I didn't get you!


this what inside the double quotation, the error message .

Failed to evaluate the script:
Python exception: (unicode error) 'utf-8' codec can't decode byte 0xe9 in position 35: invalid continuation byte (mvsfunc.py, line 1267)

Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 1847, in
vapoursynth.vpy_evaluateScript
File "C:/Users/G_N-A/Desktop/VapourSynthEditor-r16-64bit/Untitled.vpy", line 4, in
File "C:\Users\G_N-A\AppData\Local\Programs\Python\Python36\Lib\fvsfunc.py", line 4, in
import havsfunc as haf # https://github.com/HomeOfVapourSynthEvolution/havsfunc
File "C:\Users\G_N-A\AppData\Local\Programs\Python\Python36\Lib\havsfunc.py", line 2, in
import mvsfunc as mvf
File "C:\Users\G_N-A\AppData\Local\Programs\Python\Python36\Lib\mvsfunc.py", line 1267
"""
^
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe9 in position 35: invalid continuation byte

Boulder
30th May 2018, 17:08
Have you checked that the file mvsfunc.py is not broken? I.e. open it in Notepad++ and see what that line shows.