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 10th November 2020, 20:10   #4101  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by feisty2 View Post
there's no preset for audio formats?
No, trivial to query so I didn't see any real need. Also they can't be properly serialized into a single int.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 10th November 2020, 20:39   #4102  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by feisty2 View Post
is it possible to change the API for releaseFrameEarly to void(const VSFrameRef*, VSFrameContext*) (release directly from a frame object rather than from a node object)?
the current API kind of breaks RAII for C++, a frame object always keeps the ownership of its underlying frame reference, if a frame reference is released from a node, there's no way to inform the frame object who's keeping the ownership of the reference that the reference has expired, and there will be a "double free" error after getFrame() returns.
No, releaseFrameEarly() is more or less deprecated and useless for 99.99% of filters. Write a wrapper that caters to the masses instead.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 16th November 2020, 20:06   #4103  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
how do I obtain the return value of the function that is passed to createFunc() in python?

Code:
// C++ code, inside getFrame()
auto f = [](auto in, auto out, auto, auto, auto) {
	vsapi->propSetFloat(out, "val", 2.71, VSPropAppendMode::paReplace);
	vsapi->logMessage(VSMessageType::mtWarning, "aaaaaaa");
};

auto fp = Function{ vsapi->createFunc(f, nullptr, [](auto) {}, core, vsapi) };
ProcessedFrame["test"] = fp;


#Python script
clip = core.test.Test(clip)
x = clip.get_frame(0).props['test']() # prints "aaaaaaa" as expected, however x is of type None rather than float
feisty2 is offline   Reply With Quote
Old 16th November 2020, 22:32   #4104  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
it seems the problem is caused by Func.__call__() discarding its return value: https://github.com/vapoursynth/vapou...synth.pyx#L636
this "ret" thing, after receiving whatever stored in the out map, was never returned by __call__ and was simply discarded.
is this a bug?
feisty2 is offline   Reply With Quote
Old 19th November 2020, 11:43   #4105  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
is the message handler attached to each core and no longer global in API v4?
feisty2 is offline   Reply With Quote
Old 19th November 2020, 11:53   #4106  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by feisty2 View Post
is the message handler attached to each core and no longer global in API v4?
Correct
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 19th November 2020, 12:02   #4107  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
what's the use of removeMessageHandler()? it seems I can remove the current handler by simply passing a NULL handler to addMessageHandler()?
who owns the char pointer that the handler receives? is it the same pointer passed to logMessage() or a pointer to some internal deep copy of what's passed to logMessage()?
feisty2 is offline   Reply With Quote
Old 19th November 2020, 12:34   #4108  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by feisty2 View Post
what's the use of removeMessageHandler()? it seems I can remove the current handler by simply passing a NULL handler to addMessageHandler()?
who owns the char pointer that the handler receives? is it the same pointer passed to logMessage() or a pointer to some internal deep copy of what's passed to logMessage()?
addMessageHandler() simply adds one more handler, it never removes the current one
you then remove the handler by passing the handle from addMessageHandler() to removeMessageHandler()
Ownership is also optional since all handlers obviously will be removed automatically when a core is destroyed. Calling removeMessageHandler() with an invalid/already freed handle is safe and does nothing.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 19th November 2020, 12:46   #4109  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
interesting, I didn't realize there could be multiple message handlers. so logMessage() will send the message to all registered handlers?
feisty2 is offline   Reply With Quote
Old 19th November 2020, 12:49   #4110  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by feisty2 View Post
interesting, I didn't realize there could be multiple message handlers. so logMessage() will send the message to all registered handlers?
Yes

Filler here
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 21st November 2020, 20:10   #4111  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
I can't decide which is the correct design for message handlers.
should I bind the lifetime of a message handler to its descriptor, like a file descriptor?
Code:
auto md = Core.AddMessageHandler([](auto...) {});
// md is a stateful object
// automatically calls removeMessageHandler() in md's destructor when it goes out of scope
or should I let the user manage the handler's lifetime manually?
Code:
auto md = Core.AddMessageHandler([](auto...) {});
// md is a stateless integer ID / pointer

Core.Eject(md);
// explicitly ejects the handler when no longer needed.
feisty2 is offline   Reply With Quote
Old 22nd November 2020, 11:48   #4112  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
does getFrameAsync() have any special behavior (creating new threads, etc.)?
it seems the same asynchronous behavior could be achieved by simply calling getFrame() with std::async?
Code:
auto f = std::async(std::launch::async, [&] { return vsapi->getFrame(n, node, nullptr, 0); });

... // do something else while waiting for f

auto frame = f.get(); // block the current thread and retrieve the frame when needed
why should I use getFrameAsync() instead of something like the code above?
feisty2 is offline   Reply With Quote
Old 22nd November 2020, 20:49   #4113  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
I use a jpeg as source:
Code:
General
Complete name                            : c:\Users\Selur\Desktop\test.jpg
Format                                   : JPEG
File size                                : 465 KiB

Image
Format                                   : JPEG
Width                                    : 1 280 pixels
Height                                   : 534 pixels
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Compression mode                         : Lossy
Stream size                              : 465 KiB (100%)
which I open using:
Code:
clip = core.imwri.Read(["C:/Users/Selur/Desktop/test.jpg"])
clip = core.std.Loop(clip=clip, times=100)
what confuses me is that the file is reported as RGB24.
Does ImageMagick Writer-Reader (http://www.vapoursynth.com/doc/plugins/imwri.html) always return RGB or am I missing something?
In case it always returns RGB, it would be nice if this could be added to the documentation.

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 23rd November 2020, 10:36   #4114  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by Selur View Post
I use a jpeg as source:
Code:
General
Complete name                            : c:\Users\Selur\Desktop\test.jpg
Format                                   : JPEG
File size                                : 465 KiB

Image
Format                                   : JPEG
Width                                    : 1 280 pixels
Height                                   : 534 pixels
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Compression mode                         : Lossy
Stream size                              : 465 KiB (100%)
which I open using:
Code:
clip = core.imwri.Read(["C:/Users/Selur/Desktop/test.jpg"])
clip = core.std.Loop(clip=clip, times=100)
what confuses me is that the file is reported as RGB24.
Does ImageMagick Writer-Reader (http://www.vapoursynth.com/doc/plugins/imwri.html) always return RGB or am I missing something?
In case it always returns RGB, it would be nice if this could be added to the documentation.

Cu Selur
It probably always returns RGB... maybe.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 23rd November 2020, 11:46   #4115  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
some elaboration on the issue mention at #4187 would be nice...
it's hard to determine the design of the async interface without knowing the technical details of the C API. also it's a lot harder to convert a callback kind of stuff to std::future which involves locks, condition variable and other unnecessary complexity.
feisty2 is offline   Reply With Quote
Old 23rd November 2020, 12:44   #4116  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by feisty2 View Post
some elaboration on the issue mention at #4187 would be nice...
it's hard to determine the design of the async interface without knowing the technical details of the C API. also it's a lot harder to convert a callback kind of stuff to std::future which involves locks, condition variable and other unnecessary complexity.
Internally getFrame() is implemented as a function that waits for getFrameAsync() to return. So I guess wrapping getFrame() in a future would be close at least. But with a lot of unnecessary locking and bookkeeping added.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is online now   Reply With Quote
Old 26th November 2020, 14:06   #4117  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
I think "id" should be a member of VSVideoFormat in API v4, otherwise it requires access to the core to determine if a clip has a constant format which is not very convenient
feisty2 is offline   Reply With Quote
Old 26th November 2020, 14:11   #4118  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
or at least make the core parameter optional for queryVideoFormatID()
feisty2 is offline   Reply With Quote
Old 26th November 2020, 22:11   #4119  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
it seems API v4 uses the colorfamily to determine if a format is constant, that's a bit weird...
feisty2 is offline   Reply With Quote
Old 28th November 2020, 18:53   #4120  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Is there an "autowhite" filter which is more clever than the example over at http://www.vapoursynth.com/doc/functions/frameeval.html ?
__________________
Hybrid here in the forum, homepage
Selur 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 12:07.


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