View Single Post
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