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 27th December 2017, 23:07   #1  |  Link
Stephen R. Savage
Registered User
 
Stephen R. Savage's Avatar
 
Join Date: Nov 2009
Posts: 337
How to run Avisynth scripts within VapourSynth

README:
Quote:
Embed 32-bit Avisynth 2.6 or Avisynth+ environment within 64-bit VapourSynth.

Code:
avsw.Eval(string script, clip[] "clips", string[] "clip_names", string "avisynth", string "slave", string "slave_log")
script - Avisynth script fragment
clips - VapourSynth clips ("nodes") to inject into Avisynth environment
clip_names - Avisynth variable name corresponding to injected clip
avisynth - Path to Avisynth DLL. The default uses the process DLL search path.
slave - Path to avshost_native.exe slave procecss. The plugin path is searched by default.
slave_log - Log file for slave process.

The function returns the result of the Avisynth script, which may be an integer, float, string, or clip. If the result is a clip, the name of the return value is "clip", otherwise it is "result".
Example:
Code:
import vapoursynth as vs

core = vs.get_core()

red = core.std.BlankClip(color=[255, 0, 0])
green = core.std.BlankClip(color=[0, 255, 0])
# Before executing the Avisynth script, "r" and "g" are set to the bound clips.
c = core.avsw.Eval("Merge(r, g)", clips=[red, green], clip_names=["r", "g"])
c.set_output()
Link.

Last edited by Stephen R. Savage; 13th January 2018 at 18:48.
Stephen R. Savage is offline   Reply With Quote
Old 28th December 2017, 01:53   #2  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
NICE!!

Code:
c = core.std.BlankClip(color=[255, 0, 0])
c = core.avsw.eval('AddAutoloadDir("D:\\AvisynthRepository\\SCRIPTS") mpeg2source("D:\\01.d2v") AnimeIVTC(mode=1)', clips=[c], clip_names=["last"])
clip=c

This avs script crashed via Avisource and with avfs.exe, but avsproxy is stable.

Two questions:
- Is it possible to use avisynth x64 with this filter?
- Would be a "portable" avisynth possible as long as avisynth.dll is in the same folder? (or via path parameter in avsw)
__________________
Search and denoise

Last edited by ChaosKing; 28th December 2017 at 01:56.
ChaosKing is online now   Reply With Quote
Old 28th December 2017, 02:15   #3  |  Link
Stephen R. Savage
Registered User
 
Stephen R. Savage's Avatar
 
Join Date: Nov 2009
Posts: 337
Quote:
Originally Posted by ChaosKing View Post
Two questions:
- Is it possible to use avisynth x64 with this filter?
You can load 64-bit plugins directly. It looks like your script does not need the clip binding feature, so you should be able to use VFW.
Quote:
- Would be a "portable" avisynth possible as long as avisynth.dll is in the same folder? (or via path parameter in avsw)
You can provide the Avisynth library path via "avisynth" argument (link in original post updated).

Last edited by Stephen R. Savage; 28th December 2017 at 02:18.
Stephen R. Savage is offline   Reply With Quote
Old 28th December 2017, 14:46   #4  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Hollola, Finland
Posts: 4,452
Holy smoke, thank you very much! I've been waiting to get my hands on SmoothD2 in 64-bit Vapoursynth since we are still waiting for a proper port, and with this tool, it's possible
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 28th December 2017, 16:53   #5  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
Quote:
Originally Posted by Stephen R. Savage View Post
You can load 64-bit plugins directly. It looks like your script does not need the clip binding feature, so you should be able to use VFW.
But I can't load avs scripts directly ( AnimeIVTC is a script )
And loading my sample script via VFW aka Avisource is not possible -> instant crash in VS ( No problems in Virtualdub-64). That's why I asked if x64 would possible.
__________________
Search and denoise
ChaosKing is online now   Reply With Quote
Old 28th December 2017, 18:36   #6  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,876
Quote:
Originally Posted by ChaosKing View Post
But I can't load avs scripts directly ( AnimeIVTC is a script )
And loading my sample script via VFW aka Avisource is not possible -> instant crash in VS ( No problems in Virtualdub-64). That's why I asked if x64 would possible.
Instant crash? Does it output any error like bad mmx state if you try to output it with vspipe?
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 28th December 2017, 19:44   #7  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
No output. Tested like this with R41-test4

Code:
.\VSPipe.exe -i 'D:\Test.vpy' .
My vs script
Code:
clip = core.avisource.AVISource(r'D:\ivtc.avs')
clip.set_output()
But it works without tfm or animeivtc.
Code:
AddAutoloadDir("D:\AvisynthRepository\SCRIPTS")
mpeg2source("D:\01\VTS_01_CHAPTER_03_1.d2v")
tfm(mode=6, PP=5,  slow =2, d2v="D:\01\VTS_01_CHAPTER_03_1.d2v") <- bad boy

But this forced me to switch to vivtc, and after some conditionalDeintStillCombed magic I got similar/better results.
__________________
Search and denoise

Last edited by ChaosKing; 28th December 2017 at 19:47.
ChaosKing is online now   Reply With Quote
Old 28th December 2017, 20:27   #8  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,876
Quote:
Originally Posted by ChaosKing View Post
No output. Tested like this with R41-test4

Code:
.\VSPipe.exe -i 'D:\Test.vpy' .
My vs script
Code:
clip = core.avisource.AVISource(r'D:\ivtc.avs')
clip.set_output()
But it works without tfm or animeivtc.
Code:
AddAutoloadDir("D:\AvisynthRepository\SCRIPTS")
mpeg2source("D:\01\VTS_01_CHAPTER_03_1.d2v")
tfm(mode=6, PP=5,  slow =2, d2v="D:\01\VTS_01_CHAPTER_03_1.d2v") <- bad boy

But this forced me to switch to vivtc, and after some conditionalDeintStillCombed magic I got similar/better results.
Can you put all the scripts and a sample script and the plugins into an archive? That way I can test with the same versions as you and don't need to go on a treasure hunt. And reveal your avisynth version too while you're at it. I'd really like to get to the bottom of this...
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 28th December 2017, 22:26   #9  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
Here is my x64 r2544 avs folder (plugins, scripts & sample script)
LINK

//EDIT
Same crash with r2580
__________________
Search and denoise

Last edited by ChaosKing; 28th December 2017 at 22:34.
ChaosKing is online now   Reply With Quote
Old 29th December 2017, 00:01   #10  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
Thx, woking now. Loading an external avisynth.dll too!
__________________
Search and denoise
ChaosKing is online now   Reply With Quote
Old 29th December 2017, 17:47   #11  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,876
Quote:
Originally Posted by ChaosKing View Post
Here is my x64 r2544 avs folder (plugins, scripts & sample script)
LINK

//EDIT
Same crash with r2580
I found one crash in avisource. Try it again when I release the next R41 build.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 30th December 2017, 19:49   #12  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,876
Quote:
Originally Posted by ChaosKing View Post
Here is my x64 r2544 avs folder (plugins, scripts & sample script)
LINK

//EDIT
Same crash with r2580
Try again with R41-RC1
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 30th December 2017, 20:22   #13  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
Quote:
Originally Posted by Myrsloik View Post
Try again with R41-RC1
Code:
vapoursynth.Error: Avisynth read error:
CAVIStreamSynth: System exception - Access Violation at 0x000001D41A5DB6D0
2017-12-30 20:16:58.862
Core freed but 460800 bytes still allocated in framebuffers
Core freed but 460800 bytes still allocated in framebuffers
2017-12-30 20:17:05.392
Bad MMX state detected when creating new core
same error in vspipe and vs editor, only that the mmx line is only shown in the vs editor. Tested with colorbars() + tfm(mode=6)
__________________
Search and denoise
ChaosKing is online now   Reply With Quote
Old 30th December 2017, 20:29   #14  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,876
Quote:
Originally Posted by ChaosKing View Post
Code:
vapoursynth.Error: Avisynth read error:
CAVIStreamSynth: System exception - Access Violation at 0x000001D41A5DB6D0
2017-12-30 20:16:58.862
Core freed but 460800 bytes still allocated in framebuffers
Core freed but 460800 bytes still allocated in framebuffers
2017-12-30 20:17:05.392
Bad MMX state detected when creating new core
same error in vspipe and vs editor, only that the mmx line is only shown in the vs editor. Tested with colorbars() + tfm(mode=6)
At least we're making progress. It happens because of a bug in one of the avisynth plugins. Comment out the script gradually and locate which one it is. Someone forgot to use the emms instruction. Find the plugin author and shame them, or update to the latest version of whatever plugin it is.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 30th December 2017, 20:37   #15  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
Working now. I had an old x64 TIVTC.dll from 2010, don't know why :-/
No problems with: https://github.com/pinterf/TIVTC/releases

EDIT: I guess I took it from this (outdated) list http://avisynth.nl/index.php/AviSynth%2B_x64_plugins

EDIT2: But it's still interessting that it only crashes in VS and not in VdubMod
__________________
Search and denoise

Last edited by ChaosKing; 30th December 2017 at 20:48.
ChaosKing is online now   Reply With Quote
Old 7th January 2018, 11:07   #16  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
I should be able to pass a VS clip to Avisynth, right?

Because this works

Code:
c = core.avsw.eval('blankclip() Subtitle("Hello world!") ')
but not this
Code:
c = core.std.BlankClip(color=[255, 0, 0])
c = core.avsw.eval('Subtitle("Hello world!") ', clips=[c], clip_names=["last"])
vapoursynth.Error: Avisynth 32-bit proxy: command failed
__________________
Search and denoise
ChaosKing is online now   Reply With Quote
Old 8th January 2018, 01:27   #17  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
The original from Soureforge works, also 2.6 (MT) from here https://forum.doom9.org/showthread.php?t=148782

But the colors are shifted https://www.dropbox.com/s/7lft4ek963...color.PNG?dl=0

AVS+ would be nice for 16bit support (if possible)
__________________
Search and denoise

Last edited by ChaosKing; 8th January 2018 at 01:29.
ChaosKing is online now   Reply With Quote
Old 13th January 2018, 11:55   #18  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
I totally forgot about stack16, thanks for the reminder!

Found a new issue:
I tried CropResize from here https://forum.doom9.org/showthread.php?t=175114 with Autocrop, but it gets stuck. Without AutoC=true it's ok. There's no output in vspipe. tested with avs+ and 2.6
Code:
core.avsw.Eval('AddAutoloadDir("D:\AvisynthRepository\SCRIPTS") pCropResize(AutoC=true)', clips=[c], clip_names=["last"], slave_log=r"D:\x.txt", avisynth =r"D:\AvisynthRepository\AVSPLUS_x86\Avisynth.dll")
Code:
[observe @ :376] load avisynth DLL from 'D:\AvisynthRepository\AVSPLUS_x86\Avisynth.dll'
[send_async @ :465] async send command type 0: 4294967295
[recv_thread_func @ :295] received command type 6: 4294967295 => 1
[observe @ :457] set script var 'last'
[observe @ :466] remote clip 0: 720x480 1/1/1
[send_async @ :465] async send command type 0: 4294967295
[recv_thread_func @ :295] received command type 7: 4294967295 => 2
[observe @ :501] begin eval script
AddAutoloadDir("D:\AvisynthRepository\SCRIPTS") pCropResize(AutoC=true)[observe @ :503] end eval script
[GetFrame @ :288] clip 0 frame 1 not prefetched
[send_sync @ :492] sync send command type: 8
[send_async @ :465] async send command type 8: 0
__________________
Search and denoise
ChaosKing is online now   Reply With Quote
Old 15th January 2018, 00:54   #19  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 490
Works flawlessly

EDIT: currently an avs error msg is not show like in virtualdub (or any other tool). It would be nice to see the actual avs error rather than "vapoursynth.Error: Avisynth 32-bit proxy: command failed". It's a nice to have feature (and if it isn't too hard to implement)
__________________
Search and denoise

Last edited by ChaosKing; 15th January 2018 at 01:02.
ChaosKing is online now   Reply With Quote
Old 18th January 2018, 19:51   #20  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Hollola, Finland
Posts: 4,452
Quote:
Originally Posted by ChaosKing View Post
2.6 and avs+
Code:
AttributeError: There is no function named eval
What does this error actually mean? I was trying to test this script and got the message. The sample script from the first post works fine.

Code:
import vapoursynth as vs

core = vs.get_core()
core.avs.LoadPlugin(r'C:\\Program Files\\VapourSynth\\avs64\DGDecodeNV.dll')

c = core.avs.DGSource(r'C:\Temp\test.dgi')

clp = core.avsw.eval('SmoothD2(quant=2, shift=4)', clips=[c], clip_names=["last"])

clp.set_output()
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Reply

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 00:05.


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