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. |
1st June 2018, 03:48 | #2 | Link |
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
read the fucking manual, it's a plain c api. there's a c++ wrapper if you prefer that, and someone also made a rust wrapper, but I don't think I've seen a C# wrapper
if you want to evaluate .vpy scripts, there's a separate api for that. Last edited by TheFluff; 1st June 2018 at 03:52. |
1st June 2018, 18:13 | #4 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Creating a C# wrapper around raw C API is something I've never done and would be way too much work; was hoping someone might have done it.
I'm better to open it in a MPlayer control, which does have a .NET wrapper around its console interface. |
1st June 2018, 18:20 | #5 | Link | |
Guest
Posts: n/a
|
Quote:
https://docs.microsoft.com/en-us/cpp...-using-pinvoke Since you're dealing with a sane, C API it should be pretty straightforward. |
|
1st June 2018, 21:43 | #7 | Link | ||
Guest
Posts: n/a
|
Quote:
Quote:
|
||
2nd June 2018, 00:45 | #8 | Link | ||
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
ok this look quite straightforward; except that it uses a lot of C objects that would make it difficult to invoke via .NET
Function GetOutput is what looks relevant Quote:
Quote:
Basically what I want to know is how to read a frame at designed position, and parse it as a RGB displayable image. Is there anything to help convert the output for display? This really does look like a complex path. |
||
2nd June 2018, 01:19 | #9 | Link | |||
Guest
Posts: n/a
|
So then you have to use the core API as well:
Quote:
Quote:
Once your done free the frame: Quote:
Last edited by amichaelt; 2nd June 2018 at 01:46. |
|||
2nd June 2018, 03:03 | #10 | Link | |
Useful n00b
Join Date: Jul 2014
Posts: 1,667
|
Quote:
https://github.com/vapoursynth/vapou...ript_example.c |
|
2nd June 2018, 03:14 | #11 | Link | |
Quality Checker
Join Date: Aug 2013
Posts: 285
|
Quote:
__________________
I love Doom9 |
|
2nd June 2018, 03:56 | #12 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
OK getting closer; would be lots of work but it's doable.
For YV12 to RGB32 conversion for display, what other option do I have besides appending a conversion at the end of the script file? Even there, VapourSynth doesn't support any stacked format. |
3rd June 2018, 19:57 | #14 | Link | |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
Quote:
|
|
6th June 2018, 23:32 | #15 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
SWIG generates a whole lot of classes to manage the interface. Does it have to be so complex or can the C interface be called in a simple way?
I'm looking at the first function vsscript_getVSApi2 https://github.com/vapoursynth/vapou...VSScript.h#L75 It returns a pointer to an object of type VSAPI. Which is a very complex object. https://github.com/vapoursynth/vapou...urSynth.h#L242 What's the best way of handling it? Use the SWIG complex code or do it otherwise? Furthermore, SWIG on VapourSynth.h returns these errors Code:
swig -csharp -module VsApi _\VapourSynth.h _\VapourSynth.h(193) : Warning 451: Setting a const char * variable may leak memory. Unable to open file _\SWIGTYPE_p_f_p_q_const__struct_VSMap_p_struct_VSMap_p_q_const__char_p_f_p_struct_VSMap_p_struct_VSMap_p_p_void_p_struct_VSNode_p_struct_VSCore_p_q_const__struct_VSAPI__void_ p_f_int_int_p_p_void_p_p_void_p_struct_VSFrameContext_p_struct_VSCore_p_q_const__struct_VSAPI__p_q_const__struct_VSFrameRef_p_f_p_void_p_struct_VSCore_p_q_const__struct_VSAPI__void_int_int_p_void_p_ struct_VSCore__void.cs: No such file or directory Code:
swig -csharp -module VsApi -lvapoursynth.h VSScript.h VSScript.h(39) : Error: Syntax error in input(1).
__________________
FrameRateConverter | AvisynthShader | AvsFilterNet | Natural Grounding Player with Yin Media Encoder, 432hz Player, Powerliminals Player and Audio Video Muxer Last edited by MysteryX; 7th June 2018 at 00:09. |
7th June 2018, 00:02 | #16 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
VFW avifile API could be a simpler option, but then it requires VapourSynth to be properly installed on the machine so that the codec is recognized. The advantage of using the VapourSynth API directly is that I can deploy VapourSynth.dll and don't need it to be installed on the machine; I don't rely on codec configuration.
|
7th June 2018, 17:55 | #17 | Link | |||
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
OK. Several bad advice were given; and I'm encountering some issues.
Quote:
Quote:
Quote:
Calling the C++ API within VapourSynth.h is very complex. VsScript exposes a plain C interface to simplify that, and I should stick to it. I believe vsscript_getOutput is what I need to call GetFrame. Knowing what to do with VSNodeRef, however, may be more complex. Now if I do just this it works Code:
[DllImport(VsScriptDll, CallingConvention=CallingConvention.Cdecl)] public static extern int vsscript_getApiVersion(); Code:
[DllImport(VsScriptDll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int vsscript_evaluateScript(ref IntPtr handle, [MarshalAs(UnmanagedType.LPStr)]string script, [MarshalAs(UnmanagedType.LPStr)]string scriptFileName, int flags);
__________________
FrameRateConverter | AvisynthShader | AvsFilterNet | Natural Grounding Player with Yin Media Encoder, 432hz Player, Powerliminals Player and Audio Video Muxer Last edited by MysteryX; 7th June 2018 at 19:33. |
|||
7th June 2018, 19:06 | #18 | Link |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
UTF8 is a type of Unicode...
Yes, everything in VapourSynth expects char* to contain null-terminated UTF8. The calling convention in VapourSynth is stdcall (see the VS_CC macro in VapourSynth.h).
__________________
Buy me a "coffee" and/or hire me to write code! |
7th June 2018, 19:36 | #19 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Unicode is 2-byte per char, UTF8 is either 1 or 2 bytes per char. Completely different encoding.
I did find some information about how to do it here but I have to do the work manually; automatic marshal won't help me here. http://blog.kutulu.org/2012/04/marsh...-it-ought.html |
7th June 2018, 20:04 | #20 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
OK I have successfully handled the functions in VsScript, in a nice managed class that handles all allocations and deallocations and UTF8 pointer conversions.
vsscript_getOutput returns VSNodeRef. Now what do I do with it? It looks like I'll have to dive into VapourSynth.h too for the rest. For VsScript functions, this is working fine. Code:
[DllImport(VsScriptDll)] public static extern int vsscript_evaluateFile(ref IntPtr handle, IntPtr scriptFilename, int flags); I see GetFrame takes the VSNodeRef as input parameter and gives VSFrameRef as output. From there, I suppose the other relevant functions are getReadPtr(plane) and getVideoInfo. What else do I need? |
|
|