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 30th June 2013, 05:20   #821  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 595
Code:
>>> import vapoursynth as vs
>>> core = vs.get_core()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "vapoursynth.pyx", line 777, in vapoursynth.get_core (src\cython\vapoursy
nth.c:12897)
vapoursynth.Error: 'Internal environment id not set. Was get_core() called from
a filter callback?'
>>>
what's 'Internal environment id' ?
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 30th June 2013, 11:37   #822  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,402
Quote:
Originally Posted by Chikuzen View Post
Code:
>>> import vapoursynth as vs
>>> core = vs.get_core()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "vapoursynth.pyx", line 777, in vapoursynth.get_core (src\cython\vapoursy
nth.c:12897)
vapoursynth.Error: 'Internal environment id not set. Was get_core() called from
a filter callback?'
>>>
what's 'Internal environment id' ?
I forgot that scripts could also be called from outside of vsscript. I'll post a third test version a bit later today.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 30th June 2013, 16:01   #823  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,402
Here's a third test.

Changes:
Possibly fixed the "python in python" crash, now it at least gets past vseval_init() on my computer (seemed to be caused by differences in GIL state)
Fixed the error that happend when not running scripts through vsscript
VSScript tells python to no install its signal handlers when loaded
Fixed the fps printed in vspipe's info
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 30th June 2013, 18:03   #824  |  Link
mastrboy
Registered User
 
Join Date: Sep 2008
Posts: 304
Myrsloik: What are the advantages of running a native compiled vapoursynth plugin versus loading a plugin with core.avisynth.LoadPlugin() ?
__________________
(i have a tendency to drunk post)
mastrboy is offline   Reply With Quote
Old 30th June 2013, 18:07   #825  |  Link
vdcrim
Registered User
 
Join Date: Dec 2011
Posts: 193
Updated list of head-scratchers:
  • The sys.path thing (for both vsscript and VfW). Other result of this (because is fixed by setting PYTHONHOME): if vsscript is called from Python 3.2 it crashes at vseval_evaluateScript.
  • Issues if vsscript is called from (and only from) Python 3.3: the OSError exception at vseval_init is fixed in test3, vseval_evaluateScript also passes (the gist linked a bit above is now Python 3 compatible) but the process gets stuck at vseval_finalize.
vdcrim is offline   Reply With Quote
Old 30th June 2013, 18:22   #826  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,402
Quote:
Originally Posted by mastrboy View Post
Myrsloik: What are the advantages of running a native compiled vapoursynth plugin versus loading a plugin with core.avisynth.LoadPlugin() ?
If you don't need any features beyond what avisynth 2.5 offers and the plugin can't be easily changed to a better threading model (rare), nothing.

The key here is that x64 builds for windows are coming in a bit and then old avisynth stuff just won't work. (and don't think avisynth x64 plugins is the answer, since they're usually "delete key" ports and run slower than the 32-bit equivalents)

A properly written vs plugin also has the advantage of being compiled/used on any OS. I think of this as a new start where I and some other people slowly port/rewrite the most popular parts of avisynth's filters so they finally work in a modern environment everywhere...
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 30th June 2013, 20:02   #827  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 595
BTW, where did this feature go?
Quote:
list_functions() renamed to get_plugins() for the core and get_functions() for namespaces,
it also returns a dict instead of a string now
new list_functions() is hard to use.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 30th June 2013, 20:03   #828  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,402
Quote:
Originally Posted by Chikuzen View Post
BTW, where did this feature go?

new list_functions() is hard to use.
Hard to use in what way? What do you want changed? Should I restore the old list_functions() too for an easier to read format?
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet

Last edited by Myrsloik; 30th June 2013 at 20:05.
Myrsloik is offline   Reply With Quote
Old 30th June 2013, 21:45   #829  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,402
Have a fourth test version.

This version restores list_functions(). get_functions()/get_plugins() is available to get dicts which are easier to deal with if programs want to enumerate everything.
It also fixes the "python in python" issue for python 3.3 and kinda other versions (insert huge asterisk here about vseval_finalize() hanging).

Keep testing. At this rate this will actually be a fairly stable release.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 1st July 2013, 10:13   #830  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,402
Quote:
Originally Posted by HolyWu View Post
Is the bug in Expr for > 8 bit formats reported by 06_taro not to be fixed yet?

BTW, could the 'planes' argument of Lut/Lut2 be set to [0, 1, 2] by default(all planes will be processed), thus make it an optional argument?
I completely missed that expr was also mentioned. Will take a look at it tonight. Changing the default also makes sense i guess.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 3rd July 2013, 15:22   #831  |  Link
zettai
Fascinated Lurker
 
zettai's Avatar
 
Join Date: Feb 2002
Location: Durham, UK
Posts: 243
Has anyone managed to get access to a frame's image with vapoursynth via a numpy array or a pillow image or similar?
zettai is offline   Reply With Quote
Old 3rd July 2013, 16:23   #832  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 595
Quote:
Originally Posted by zettai View Post
Has anyone managed to get access to a frame's image with vapoursynth via a numpy array or a pillow image or similar?
I have previewed using PIL before since there was no VFW module at that time.

Code:
#vsshow.py
import vapoursynth as vs
from ctypes import *
from PIL import Image

def show(core, clip, frame_number, vflip=1):
    format = clip.format.id
    width = clip.width
    height = clip.height
    if format == vs.GRAY16:
        clip = core.resize.Point(clip, width, height, vs.GRAY8)
    if format != vs.GRAY8 and format != vs.RGB24:
        clip = core.resize.Bicubic(clip, width, height, vs.COMPATBGR32)

    format = clip.format.id
    planes = range(clip.format.num_planes)
    frame = clip.get_frame(frame_number)
    data = [(frame.get_read_ptr(p), frame.get_stride(p)) for p in planes]
    buff = [b'\0' * data[p][1] * height for p in planes]
    for p in planes:
        memmove(buff[p], data[p][0], data[p][1] * height)

    if format == vs.COMPATBGR32:
        mode, src = 'RGBA', 'BGRA'
    else:
        mode, src = 'L', 'L'
    img = [Image.frombytes(mode, (width, height), buff[p], 'raw', src,
                           data[p][1], vflip) for p in planes]
    if len(planes) != 1:
        img = Image.merge('RGB', (img[2], img[0], img[1]))
    else:
        img = img[0]

    img.show()
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 4th July 2013, 13:43   #833  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 595
@Myrsloyk
Would you add a function like avisynth's "Import" for VSScript?
It is annoy that the code for preparing a buffer, opening and reading a file and closing it must be written each time.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 5th July 2013, 12:27   #834  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,402
Quote:
Originally Posted by Chikuzen View Post
@Myrsloyk
Would you add a function like avisynth's "Import" for VSScript?
It is annoy that the code for preparing a buffer, opening and reading a file and closing it must be written each time.
I guess I'll add a function to evaluate a script file as well.

Anyway, Zor finally updated the build system and ported VapourSynth to powerpc and arm. Have fun testing it on your ancient mac or something.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 5th July 2013, 13:33   #835  |  Link
vdcrim
Registered User
 
Join Date: Dec 2011
Posts: 193
AviSynth's Import does a pair of extra things besides opening and evaluating the file:
  • Change the working directory to the script's parent directory before evaluating it (to allow use of relative paths).
  • Set some global variables: ScriptName, ScriptFile, ScriptDir.
Will VapourSynth do something similar? Maybe by passing an optional filename string to vseval_evaluateScript. That way future applications using evaluate instead of import won't have to care about mirroring this behaviour themselves.
vdcrim is offline   Reply With Quote
Old 5th July 2013, 14:13   #836  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,042
Quote:
Originally Posted by vdcrim View Post
AviSynth's Import does a pair of extra things besides opening and evaluating the file:

Change the working directory to the script's parent directory before evaluating it (to allow use of relative paths).
No it does not. It sets the current directory to the directory in which the script resides.
Groucho2004 is offline   Reply With Quote
Old 5th July 2013, 14:16   #837  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 595
Quote:
Originally Posted by vdcrim View Post
AviSynth's Import does a pair of extra things besides opening and evaluating the file:
  • Change the working directory to the script's parent directory before evaluating it (to allow use of relative paths).
  • Set some global variables: ScriptName, ScriptFile, ScriptDir.
Will VapourSynth do something similar? Maybe by passing an optional filename string to vseval_evaluateScript. That way future applications using evaluate instead of import won't have to care about mirroring this behaviour themselves.
My wish is contracting line 186 to 209 of this code to four lines like
Code:
if (vseval_new_function(&se, source)) {
    env->ThrowError("VapourSource: failed to evaluate script.\n%s",
                      vseval_getError(se));
}
of cource, without QtCore.
__________________
my repositories

Last edited by Chikuzen; 5th July 2013 at 14:21.
Chikuzen is offline   Reply With Quote
Old 5th July 2013, 14:48   #838  |  Link
vdcrim
Registered User
 
Join Date: Dec 2011
Posts: 193
Quote:
Originally Posted by Groucho2004 View Post
No it does not. It sets the current directory to the directory in which the script resides.
Isn't that what I said?

On second thought adding that functionality to vseval_evaluateScript may be a bad idea and doesn't solve the general problem: import might do things besides opening and evaluating the script (not necessarily limited to what AviSynth currently does), and someone using evaluate (because there's not file) would have to check the code and implement it themselves. Then the best would be adding to the API something like ImportFile and ImportBuffer instead of a single import.
vdcrim is offline   Reply With Quote
Old 5th July 2013, 15:52   #839  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,042
Quote:
Originally Posted by vdcrim View Post
Isn't that what I said?
No. The script's parent directory is not the script's directory.
Groucho2004 is offline   Reply With Quote
Old 5th July 2013, 15:56   #840  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 2,402
I guess I'll add two new functions, vseval_importFile(&se, filename) and vseval_importBuffer(&se, scriptBuffer, imaginaryFilename) to do the things you mentioned.

I still want to keep the original function as well in case someone wants to have a different behavior.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik 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 03:55.


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