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 16th June 2005, 10:46   #1  |  Link
mg262
Clouded
 
mg262's Avatar
 
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
Run... the simplest filter I can imagine

Run

Brief description: Runs a system command.

Search keywords: run, execute, command line, command prompt, app, application, simple minimal filter.

Full description:
Run(clip, string command) - runs command and returns clip unchanged.

Example:
Blankclip
Run("Echo some text > test.txt")


Notes:
- I should really have made it work without the clip argument... but then I would have had to spend time and space figuring out IClip instead of GenericVideoFilter, and that would defeat the other point, which is:

- The title wasn't entirely tongue in cheek; I thought someone might at some point find really really minimal filter code (W/O any graphics processing) useful when starting to program them... so here it is.

#include "stdafx.h" //includes avisynth.h
#include <stdlib.h>

class Run : public GenericVideoFilter
{
public:
Run(PClip _child, const char *command, IScriptEnvironment *env);
};

Run::Run(PClip _child, const char *command, IScriptEnvironment *env) : GenericVideoFilter(_child)
{
system(command);
}

AVSValue __cdecl Create_FilterName(AVSValue args, void *user_data, IScriptEnvironment *env)
{
return new Run(args[0].AsClip(), args[1].AsString(), env);
}

extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment *env)
{
env->AddFunction("Run", "cs", Create_FilterName, 0);
return "Run plugin";
}


Edit:
After I wrote this I thought of a few more keywords to search for and...
http://forum.doom9.org/showthread.php?t=46506 ('CALL' plug-in.)

Last edited by mg262; 16th June 2005 at 19:00.
mg262 is offline   Reply With Quote
Old 16th June 2005, 12:00   #2  |  Link
Bidoche
Avisynth 3.0 Developer
 
Join Date: Jan 2002
Location: France
Posts: 639
You do not have to handle clips to do that.

Just have the run function takes a string, return void, and execute the string as a command when called.
Bidoche is offline   Reply With Quote
Old 16th June 2005, 12:45   #3  |  Link
mg262
Clouded
 
mg262's Avatar
 
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
Quote:
Originally Posted by Bidoche
You do not have to handle clips to do that.
That's true... Thank you.

But actually where I want it the pass-through is quite convenient. I've never (despite a few searches) been sure whether overloading is legal in AVISynth? I.e.

env->AddFunction("Run", "cs", RunPassThrough, 0);
env->AddFunction("Run", "s", RunDirect, 0);

Edit:
(I know the pass-through can be done with the function as well!)
mg262 is offline   Reply With Quote
Old 16th June 2005, 18:55   #4  |  Link
stickboy
AviSynth Enthusiast
 
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,268
Didn't Nic make a Call plug-in that does this?
stickboy is offline   Reply With Quote
Old 16th June 2005, 18:58   #5  |  Link
mg262
Clouded
 
mg262's Avatar
 
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
That's what the link at the end of the first post points to... I'll go back and make it clearer.
mg262 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 16:48.


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