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 21st September 2012, 10:05   #1  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
vsavsreader -- AviSynth script reader for VapourSynth

I wrote a VapourSynth plugin a few days ago.

This plugin works as a source filter on VapourSynth.
you will be able to use avisynth filters which does not exist yet for VS(e.g. DirectShowSource) and has some compatibility issue like ColorMatrix() with this plugin.

vsavsreader-1.0.0.zip

requirement:
VapourSynth-r30 or later
AviSYnth2.6/avisynth+
Microsoft Visual C++ 2015 Redistributable Packages
__________________
my repositories

Last edited by Chikuzen; 10th May 2016 at 12:49.
Chikuzen is offline   Reply With Quote
Old 23rd September 2012, 10:41   #2  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,372
I get this error when load the plugin:

Quote:
Traceback (most recent call last):
File "Version.py", line 6, in <module>
c.avs.LoadPlugin(path=r'C:\Temp\Python\plugins\vsavsreader.dll')
File "vapoursynth.pyx", line 741, in vapoursynth.Function.__call__ (src/cython\vapoursynth.c:10611)
vapoursynth.Error: 'Avisynth Loader: no entry point found'
Same error with vsavsreader.dll in same folder and:
c.avs.LoadPlugin('vsavsreader.dll')

VS r8
AviSynth 2.6.0a3
XP SP3
__________________
BeHappy, AviSynth audio transcoder, in Doom9 forums. NicAudio, BassAudio, audio decoders.
tebasuna51 is offline   Reply With Quote
Old 23rd September 2012, 11:35   #3  |  Link
HolyWu
Registered User
 
HolyWu's Avatar
 
Join Date: Aug 2006
Location: Taiwan
Posts: 484
You have to use c.std.LoadPlugin because vsavsreader is a native VS plugin.
HolyWu is offline   Reply With Quote
Old 23rd September 2012, 18:09   #4  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 5,372
Thanks. My mistake.
I copied other LoadPlugin without see the Readme.txt.
__________________
BeHappy, AviSynth audio transcoder, in Doom9 forums. NicAudio, BassAudio, audio decoders.
tebasuna51 is offline   Reply With Quote
Old 27th September 2012, 13:41   #5  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
updated for VS-r9
see first post.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 28th September 2012, 01:09   #6  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,803
I looked at the source and spotted this small problem:
****vsapi->propSetInt(props, "_DurationNum", ah->avs_vi->fps_denominator * n, 0);
Should be
****vsapi->propSetInt(props, "_DurationNum", ah->avs_vi->fps_denominator, 0);
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 28th September 2012, 07:20   #7  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
fixed.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 30th September 2012, 08:25   #8  |  Link
HolyWu
Registered User
 
HolyWu's Avatar
 
Join Date: Aug 2006
Location: Taiwan
Posts: 484
The clips loaded by vsavsreader could not be spliced.
HolyWu is offline   Reply With Quote
Old 1st October 2012, 12:24   #9  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,084
Hi Chikuzen, thanks for this usefull plugin.
Since there are some plugins/scripts that can work with dither's lsb in/out.
I was wondering if would it be possible to add a function that can merge msb/lsb into a compatible YUVxxxP16 format?
Reel.Deel is offline   Reply With Quote
Old 1st October 2012, 12:42   #10  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
Quote:
Originally Posted by HolyWu View Post
The clips loaded by vsavsreader could not be spliced.
I think that this is a VS's bug.

from vsstdlib.c
Code:
static int findCommonVi(const VSNodeRef **nodes, int num, VSVideoInfo *outvi, int ignorelength, const VSAPI *vsapi) {
    int mismatch = 0;
    int i;
    const VSVideoInfo *vi;
    *outvi = *vsapi->getVideoInfo(nodes[0]);

    for (i = 1; i < num; i++) {
        vi = vsapi->getVideoInfo(nodes[i]);

        if (outvi->width != vi->width || outvi->height != vi->height) {
            outvi->width = 0;
            outvi->height = 0;
            mismatch = 1;
        }

        if (outvi->format != vi->format) {
            outvi->format = 0;
            mismatch = 1;
        }

        if ((outvi->numFrames < vi->numFrames && outvi->numFrames) || (!vi->numFrames && outvi->numFrames)) {
            outvi->numFrames = vi->numFrames;

            if (!ignorelength)
                mismatch = 1;
        }
    }

    return mismatch;
}
Neither ”!=” nor "==" is used for comparison of two structs.
__________________
my repositories

Last edited by Chikuzen; 1st October 2012 at 12:52.
Chikuzen is offline   Reply With Quote
Old 1st October 2012, 12:44   #11  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
Quote:
Originally Posted by Reel.Deel View Post
Hi Chikuzen, thanks for this usefull plugin.
Since there are some plugins/scripts that can work with dither's lsb in/out.
I was wondering if would it be possible to add a function that can merge msb/lsb into a compatible YUVxxxP16 format?
use dither interleaved format.
stacked format is not supported.
Code:
clip = core.avsr.Import('foo.avs', bitdepth=16)
__________________
my repositories

Last edited by Chikuzen; 1st October 2012 at 12:47.
Chikuzen is offline   Reply With Quote
Old 1st October 2012, 12:49   #12  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,803
Quote:
Originally Posted by Chikuzen View Post
I think that this is a VS's bug.
...

Neither != nor "==" is used for comparison of two structs.
You're probably on to something in there but that comparison is legal. It's pointer to struct,not struct.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 1st October 2012, 12:58   #13  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
Quote:
Originally Posted by Myrsloik View Post
You're probably on to something in there but that comparison is legal. It's pointer to struct,not struct.
Then, is pointing out the same address right as for format of node[0] and format of node[1] ?
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 1st October 2012, 13:03   #14  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,803
I found the problem. You're never supposed to create a format struct yourself, you query it from the core.

Code:
format->id = table[i].id;
    strcpy(format->name, table[i].name);
    format->colorFamily = table[i].color_family;
    format->bitsPerSample = ah->bitdepth;
    format->bytesPerSample = (ah->bitdepth + 7) / 8;
    format->subSamplingW = table[i].subsample_w;
    format->subSamplingH = table[i].subsample_h;
    format->numPlanes = avs_is_y8(ah->avs_vi) ? 1 : 3;

    return format;
should simply be:
Code:
return vsapi->getFormatPreset(table[i].id, core);
The whole function set_vs_format() function can also be simplified to one call to vsapi->registerFormat()

something like:
Code:
return registerFormat(cmYuv/cmRgb/cmGray, stInteger, bitsPerSample, subSamplingW, subSamplingH, core);
If you register a duplicate a pointer to the already registered format struct will be returned. => the same format always has the same pointer so the comparison I make is valid.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 1st October 2012, 13:13   #15  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
ok, I understood.
Since this plugin was written when the source code had not been opened yet, I was not using vsapi in the place which needs it.
__________________
my repositories

Last edited by Chikuzen; 1st October 2012 at 13:17.
Chikuzen is offline   Reply With Quote
Old 1st October 2012, 13:21   #16  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,084
Quote:
Originally Posted by Chikuzen View Post
use dither interleaved format.
stacked format is not supported.
Code:
clip = core.avsr.Import('foo.avs', bitdepth=16)
Did not know I could do that. Thanks Chikuzen.

* Edit *

Maybe it's not such a bad idea to add that information to the readme.

Last edited by Reel.Deel; 1st October 2012 at 15:46. Reason: added suggestion
Reel.Deel is offline   Reply With Quote
Old 1st October 2012, 14:10   #17  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
fixed Splice issue.
please download fixed version from the link of first post.

I appreciate advice of Myrsloik.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 1st October 2012, 17:43   #18  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
Quote:
Originally Posted by Reel.Deel View Post
Maybe it's not such a bad idea to add that information to the readme.
I'm not good at english to write such complicated descriptions.
If you write them, I'll add them into the readme.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 2nd October 2012, 13:05   #19  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,084
Quote:
Originally Posted by Chikuzen View Post
I'm not good at english to write such complicated descriptions.
If you write them, I'll add them into the readme.
Sounds like a deal. I'll put something together in the next couple of days.

I wish my Japanese were half as good as your English.

* Edit *

Here's the description I wrote on how to import Dither's msb/lsb format into Vapoursynth.
I'm not an expert so I hope it makes sense.

Code:
VsAvsReader is able to convert Dither's interleaved MSB/LSB format into a compatible Vapoursynth YUV4xxP9/10/16 format.
Dither's MSB/LSB must be interleaved, stacked format is not supported.
Only YUV planar formats are allowed.

example 1: Use VsAvsReader's Import function to load external Avisynth script.

Vapoursynth script

	# Core
	import vapoursynth as vs
	core = vs.Core(accept_lowercase=True)

	# Import plugins
	core.std.LoadPlugin('C:/vsavsreader.dll')

	# Use "Import" to load interleaved MSB/LSB Avisynth script.
	clip = core.avsr.Import('C:/script.avs', bitdepth=16)

External Avsiynth script being imported.

        # script.avs
	LoadPlugin("C:/plugins/DGDecode.dll")
	LoadPlugin("C:/plugins/Dither.dll")
	Import("C:/scriptss/Dither.avsi")
	MPEG2Source("D:/source.d2v")
	Dither_convert_8_to_16()
	Dither_resize16(1280, 720)
	Dither_convey_yuv4xxp16_on_yvxx()

_____________________________________________________________________


Example 2: Use VsAvsReader's Eval function to create Avisynth script inside a Vapoursynth script.

Vapoursynth script

	# Core
	import vapoursynth as vs
	core = vs.Core(accept_lowercase=True)

	# Import plugins
	core.std.LoadPlugin('C:/vsavsreader.dll')

	# Use "Eval" to create interleaved MSB/LSB Avisynth script.
	lines = '''
	LoadPlugin("C:/plugins/DGDecode.dll")
	LoadPlugin("C:/plugins/Dither.dll")
	Import("C:/scriptss/Dither.avsi")
	MPEG2Source("D:/source.d2v")
	Dither_convert_8_to_16()
	Dither_resize16(1280, 720)
	Dither_convey_yuv4xxp16_on_yvxx()
	'''

	video = core.avsr.Eval(lines=lines, bitdepth=16)

Last edited by Reel.Deel; 6th October 2012 at 13:44.
Reel.Deel is offline   Reply With Quote
Old 5th October 2012, 05:58   #20  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
@Reel.Deel
added
__________________
my repositories
Chikuzen 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 04:01.


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