Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 4th October 2019, 13:50   #3561  |  Link
~ VEGETA ~
The cult of personality
 
~ VEGETA ~'s Avatar
 
Join Date: May 2013
Location: Planet Vegeta
Posts: 155
Quote:
Originally Posted by HolyWu View Post
Thanks. Fixed on github now.
can i update using vsrepo gui now?
~ VEGETA ~ is offline   Reply With Quote
Old 4th October 2019, 14:15   #3562  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
vsrepo can't update in realtime.

error 127 indicates that there is an appropriate DLL found but a required procedure export is missing. So maybe the "opencl requirements" for TCanny changed in the latest version? Or you need to install a different opencl version.
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is offline   Reply With Quote
Old 4th October 2019, 14:20   #3563  |  Link
~ VEGETA ~
The cult of personality
 
~ VEGETA ~'s Avatar
 
Join Date: May 2013
Location: Planet Vegeta
Posts: 155
Quote:
Originally Posted by ChaosKing View Post
vsrepo can't update in realtime.

error 127 indicates that there is an appropriate DLL found but a required procedure export is missing. So maybe the "opencl requirements" for TCanny changed in the latest version? Or you need to install a different opencl version.
Ok, i will update the script manually.

As for opencl, I installed latest driver which should include latest opencl. what should i do now?
~ VEGETA ~ is offline   Reply With Quote
Old 6th October 2019, 18:00   #3564  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
Doing numpy operations I discovered that returning frame from within ModifyFrame() could be numpy image and vapoursynth does not object at all. Or rather to say it is vapoursynth type of object, but they are the same. So there is no need to copy image to a new frame using f.get_write_array(), which takes time. So for example with this simple numpy operation , drawing two cross lines into vapoursynth frame takes about 10 times faster.
this it with copying a new frame:
Code:
import vapoursynth as vs
from vapoursynth import core
import numpy as np
import timeit

def numpy_process(n,f):
    start = timeit.default_timer()
    fout = f.copy()
    for p in range(3):
        plane     = np.asarray(f.get_read_array (p))
        plane_out = np.asarray(fout.get_write_array(p))
        #numpy operation with numpy image (two dimensional, because using one plane only)
        plane[360,0:1280]   =  255
        plane[0:720,640]   =  255 
        np.copyto(plane_out, plane)
    print(timeit.default_timer()-start)
    return fout
clip = core.std.BlankClip(width=1280, height=720, format = vs.RGB24)
clip = core.std.ModifyFrame(clip, clip, numpy_process)
clip.set_output()
times for rendering a frame:
Code:
0.0011401229999998819
0.0011680329999999017
0.0011924130000000588
0.001274217999999827
0.0011475010000001618
0.001175732000000096
then this code:
Code:
def numpy_process(n,f):
    start = timeit.default_timer()
    for p in range(3):
        plane     = np.asarray(f.get_read_array (p))
        plane[360,0:1280]   =  255
        plane[0:720,640]   =  255 
    print(timeit.default_timer()-start)
    return f
clip = core.std.BlankClip(width=1280, height=720, format = vs.RGB24)
clip = core.std.ModifyFrame(clip, clip, numpy_process)
clip.set_output()
renders these times for frame:
Code:
0.00011035500000033949
0.00011580899999863448
0.00011709199999998532
0.00011292100000126482
0.00011163799999991397
0.00016841999999961388
0.0001109970000001681
Was surprised by that that those frames could be overwritten directly, is there some drawback?

Last edited by _Al_; 6th October 2019 at 18:04.
_Al_ is offline   Reply With Quote
Old 6th October 2019, 18:15   #3565  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Memory corruption. Don't do it.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 6th October 2019, 18:17   #3566  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
I wanted to ask what it means, but I guess corruption means corruption, so it might fail. Thank you.
_Al_ is offline   Reply With Quote
Old 7th October 2019, 02:15   #3567  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
Spoke too soon. Getting an overlay bug, probably related to mask in R48test1 . Works ok in R46, R47.2 . But in R48test1 it's discolored

Code:
orig = core.ffms2.Source(r'testchart.png')
ovr = core.ffms2.Source(r'rgba_overlay.png')

orig_10bit444 = core.resize.Bicubic(orig, format=vs.YUV444P10, matrix_s="709")
ovrf_10bit444 = core.resize.Bicubic(ovr[0], format=vs.YUV444P10, matrix_s="709", range_s="full")
ovrm_10bit444 = core.resize.Bicubic(ovr[1], format=vs.YUV444P10, matrix_s="709", range_s="full")

overl = haf.Overlay(orig_10bit444, ovrf_10bit444, mask=ovrm_10bit444)
Image assets
https://www.mediafire.com/file/hf27n...erlay.rar/file
poisondeathray is offline   Reply With Quote
Old 7th October 2019, 09:38   #3568  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by poisondeathray View Post
Spoke too soon. Getting an overlay bug, probably related to mask in R48test1 . Works ok in R46, R47.2 . But in R48test1 it's discolored

Code:
orig = core.ffms2.Source(r'testchart.png')
ovr = core.ffms2.Source(r'rgba_overlay.png')

orig_10bit444 = core.resize.Bicubic(orig, format=vs.YUV444P10, matrix_s="709")
ovrf_10bit444 = core.resize.Bicubic(ovr[0], format=vs.YUV444P10, matrix_s="709", range_s="full")
ovrm_10bit444 = core.resize.Bicubic(ovr[1], format=vs.YUV444P10, matrix_s="709", range_s="full")

overl = haf.Overlay(orig_10bit444, ovrf_10bit444, mask=ovrm_10bit444)
Image assets
https://www.mediafire.com/file/hf27n...erlay.rar/file
Does it work if you add core.std.SetMaxCPU("none") to the top of the script?
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 7th October 2019, 14:27   #3569  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
Quote:
Originally Posted by Myrsloik View Post
Does it work if you add core.std.SetMaxCPU("none") to the top of the script?
Yes . Do you have to specify it manually now , no autodetection ?

This was on a Haswell with AVX2 only
poisondeathray is offline   Reply With Quote
Old 7th October 2019, 16:22   #3570  |  Link
DJATOM
Registered User
 
DJATOM's Avatar
 
Join Date: Sep 2010
Location: Ukraine, Bohuslav
Posts: 377
Quote:
Originally Posted by poisondeathray View Post
Yes . Do you have to specify it manually now , no autodetection ?

This was on a Haswell with AVX2 only
No, auto-detection is still works, but now we can set lower instruction set (or fallback to C routines) on purpose. For example, if there are some bugs with avx2 optimizations, you can fallback to slower but well working functions.
__________________
Me on GitHub
PC Specs: Ryzen 5950X, 64 GB RAM, RTX 2070
DJATOM is offline   Reply With Quote
Old 9th October 2019, 11:06   #3571  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Several bugs were found already. Will post a new build soon when they're fixed. Apparently Expr is broken too in some cases.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 9th October 2019, 16:17   #3572  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
Quote:
Originally Posted by Myrsloik View Post
Several bugs were found already. Will post a new build soon when they're fixed. Apparently Expr is broken too in some cases.
Was it from any of the Expr AVS+ code from pinterf? If so, is AVS+ affected too ?
poisondeathray is offline   Reply With Quote
Old 9th October 2019, 18:36   #3573  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by poisondeathray View Post
Was it from any of the Expr AVS+ code from pinterf? If so, is AVS+ affected too ?
No and no. Also it could be a bug in the expression itself now that we've investigated it a bit...
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 10th October 2019, 04:48   #3574  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
about wrapping/decorating vapoursynth core functions:
Code:
import vapoursynth as vs
from vapoursynth import core
import functools
clip = core.std.BlankClip(width=640, height=360, format=vs.YUV420P8) 

def CropAbs_extra(f):
    @functools.wraps(f)
    def wrapper(*args, **kwargs):
        print('some extra work')
        return f(*args, **kwargs)
    return wrapper

#this does not work:
#core.std.CropAbs =  CropAbs_extra(core.std.CropAbs)
#clip = core.std.CropAbs(clip, 360,240, 0,0) #to crop + some extra work
      #AttributeError: 'vapoursynth.Plugin' object has no attribute 'CropAbs'

#this works but script lines would need to be rewritten:
temp =  CropAbs_extra(core.std.CropAbs)
clip = temp(clip, 360,240, 0,0) #to crop + some extra work
I edited code above, because it did not work before.
Is there any way to keep :
clip = core.std.CropAbs(clip, 360,240, 0,0) and use a wrapper to it?
Thanks.

this does not work also:
Code:
setattr(core.std, 'CropAbs', CropAbs_extra(core.std.CropAbs))
    #AttributeError: 'vapoursynth.Plugin' object has no attribute 'CropAbs'

Last edited by _Al_; 10th October 2019 at 05:38.
_Al_ is offline   Reply With Quote
Old 10th October 2019, 22:34   #3575  |  Link
jackoneill
unsigned int
 
jackoneill's Avatar
 
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
Quote:
Originally Posted by _Al_ View Post
about wrapping/decorating vapoursynth core functions:
Code:
import vapoursynth as vs
from vapoursynth import core
import functools
clip = core.std.BlankClip(width=640, height=360, format=vs.YUV420P8) 

def CropAbs_extra(f):
    @functools.wraps(f)
    def wrapper(*args, **kwargs):
        print('some extra work')
        return f(*args, **kwargs)
    return wrapper

#this does not work:
#core.std.CropAbs =  CropAbs_extra(core.std.CropAbs)
#clip = core.std.CropAbs(clip, 360,240, 0,0) #to crop + some extra work
      #AttributeError: 'vapoursynth.Plugin' object has no attribute 'CropAbs'

#this works but script lines would need to be rewritten:
temp =  CropAbs_extra(core.std.CropAbs)
clip = temp(clip, 360,240, 0,0) #to crop + some extra work
I edited code above, because it did not work before.
Is there any way to keep :
clip = core.std.CropAbs(clip, 360,240, 0,0) and use a wrapper to it?
Thanks.

this does not work also:
Code:
setattr(core.std, 'CropAbs', CropAbs_extra(core.std.CropAbs))
    #AttributeError: 'vapoursynth.Plugin' object has no attribute 'CropAbs'
I think it's a lot more work than you want, but you can replace vs.get_core with a function that returns a fake core, which will be a wrapper object around the real core:
Code:
import vapoursynth as vs
vs.get_core = function that returns fake core

import other, stuff

core = vs.get_core()
...
I'm not sure this actually works.
__________________
Buy me a "coffee" and/or hire me to write code!
jackoneill is offline   Reply With Quote
Old 11th October 2019, 07:57   #3576  |  Link
WolframRhodium
Registered User
 
Join Date: Jan 2016
Posts: 162
Agree with jackoneill, the cython part of VS prevents you from modifying attributes of "core" and its attribute "plugin". You should define your own "core" instead.

Last edited by WolframRhodium; 12th October 2019 at 15:35.
WolframRhodium is offline   Reply With Quote
Old 11th October 2019, 16:06   #3577  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
thank you guys,
WolframRhodium thank you for the script, it might be over my head , I'll tackle it though, thank you
_Al_ is offline   Reply With Quote
Old 11th October 2019, 16:44   #3578  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
At the end of vapoursynth2.py I put:
Code:
print(core.version())
if hasattr(core, 'ffms2'):
    print('ffms2 is loaded')
else:
    print('ffms2 is not loaded')
clip = core.ffms2.Source(video.mp4)
#clip = core.std.BlankClip(width=640, height=360)#BlankClip does not create VideoNode as well
if isinstance(clip, vs.VideoNode):
    print('clip was created')
else:
    print('clip is not  vs.VideoNode')
def CropAbs_extra(f):
    @functools.wraps(f)
    def wrapper(*args, **kwargs):
        print('working in wrapper')
        return f(*args, **kwargs)
    return wrapper
print(clip)
core.std.CropAbs =  CropAbs_extra(core.std.CropAbs)  
clip = core.std.CropAbs(clip, 360,240,0,0)
print(clip)
I got output:
Code:
VapourSynth Video Processing Library
Copyright (c) 2012-2018 Fredrik Mellbin
Core R45
API R3.5
Options: -

ffms2 is loaded
clip is not  vs.videoNode
<__main__._VideoNode object at 0x00000000037B2A58>
so i t prints clip is a videonode but it does not work as a regular clip
But it does not throw any error trying to wrap that core.std.CropAbs function though, but also it is not in that wrapper.

Anyway , it might take a while to grasp it all.

Last edited by _Al_; 11th October 2019 at 16:47.
_Al_ is offline   Reply With Quote
Old 12th October 2019, 00:50   #3579  |  Link
WolframRhodium
Registered User
 
Join Date: Jan 2016
Posts: 162
Sorry for the confusion, for your code here is a tiny example.
WolframRhodium is offline   Reply With Quote
Old 12th October 2019, 01:44   #3580  |  Link
_Al_
Registered User
 
Join Date: May 2011
Posts: 321
Thank you so much.
So far I got quickly this together:

tinyvs.py:
Code:
import vapoursynth as vs
from vapoursynth import core as _vscore
import functools
class _Plugin:
    def __init__(self, namespace):
        self.__dict__.update((name, getattr(namespace, name)) for name in dir(namespace)) # func_name : func

class _Core:
    def __init__(self):
        self.__dict__.update((name, get_plugin(name)) for name in dir(_vscore)) # (namespace : (func_name : func)) or (attr_name : attr)

def get_plugin(name):
    attr = getattr(_vscore, name)
    if isinstance(attr, vs.Plugin):
        return _Plugin(attr)
    else:
        return attr

core = _Core()

def CropAbs_extra(f):
    @functools.wraps(f)
    def wrapper(*args, **kwargs):
        print('extra work with calling vs function')
        c=  f(*args, **kwargs)
        return c
    return wrapper

core.std.CropAbs =  CropAbs_extra(core.std.CropAbs)
and actual script could be:
Code:
import importlib
import tinyvs
importlib.reload(tinyvs)  #mandatory reload so wrapper always works

core = tinyvs.core

clip = core.std.BlankClip(width=640, height=360)
clip = core.std.CropAbs(clip, 360,240, 0,0)
output:
Code:
extra work with calling vs function
Thanks

Last edited by _Al_; 12th October 2019 at 01:46.
_Al_ is offline   Reply With Quote
Reply

Tags
speed, vaporware, vapoursynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 14:57.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.