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 > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st August 2012, 20:17   #1  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Can I/how to use env->Invoke to apply subtitles within filter?

I've written a filter and would like to apply a subtitle from within it - either conditionally per frame or to the whole clip at construction time (as well as doing the filter's usual stuff). I don't really understand env->Invoke(...), but is this something it can be used for?

I've tried adding
Code:
env->Invoke("invert","");
inside the constructor and GetFrame, but both result in exceptions.

David
wonkey_monkey is offline   Reply With Quote
Old 21st August 2012, 21:28   #2  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
See http://avisynth.org/mediawiki/Filter_SDK/Env_Invoke and http://avisynth.org/mediawiki/Cplusplus_API#Invoke for using Invoke.

You can also use ApplyMessage and include "text-overlay.h" (you should license your code GPL in that case though). In v2.60a3 you can also use env->ApplyMessage: http://avisynth.org/mediawiki/Cplusplus_API#ApplyMessage.2C_v5
Wilbert is offline   Reply With Quote
Old 21st August 2012, 22:36   #3  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Thanks Wilbur, that second page nudged me in the right direction.

David
wonkey_monkey is offline   Reply With Quote
Old 22nd August 2012, 00:29   #4  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
The 2nd argument is expected to be an AVSValue of type array, which is a list of the arguments to the function you are invoking.

Typically you might do something like this :-
Code:
...
  AVSValue args[1] = {child};
  AVSValue child2 = env->Invoke("invert", AVSValue(args, 1));
...
  PVideoFrame src2 = child2->GetFrame(n, env);
...
If the argument list is sparse and you need to provide the names for the arguments, then the optional 3rd argument, a matching array of string pointers, can be provided.
Code:
...
  char *text = "Foo has struck!";
...
  AVSValue args[4] = {child, text, "Courier", 48};
  char* argnames[4] = { 0, 0, "font", "size" };
  AVSValue child2 = env->Invoke("Subtitle", AVSValue(args, 4), argnames);
...
IanB 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 01:02.


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