AviSynth script を C++ で扱う

ちょいとやってみたいことがあって C もしくは C++ で avs file を開いてアレコレできないかなーと思って調べてみたらまんまな code が forum ( http://forum.doom9.org/showthread.php?t=131674 の IanB 氏の発言 http://forum.doom9.org/showthread.php?p=1064107#post1064107 ) に載っていたので写経してみた。以下は avs file の情報を command line で表示するテケトー program 。 VC++ 2008 Express Edition で build が通るのを確認 ( avisynth.lib を link したり avisynth.h にちょっと手を加えないとダメなんだけど ) 。もうちょいまともにして本来やりたかったことも実装して ( license に問題がなければ ) project file とか晒す予定、なんだけどどうなるかはわからない。

#include "stdafx.h"
#include "avisynth.h"
#include <iostream>

using namespace std;

//int _tmain(int argc, _TCHAR* argv[])
int main(int argc, char* argv[])
{
    if (argc < 2) {
        cerr << "specify file name." << endl;
        exit(-1);
    }
    cout << "target: " << argv[1] << endl;

    // build the object ScriptEnvironment
    IScriptEnvironment* se = CreateScriptEnvironment();

    // pack the filename as the argument of AviSynth filter
    AVSValue filename = argv[1];
    AVSValue args = AVSValue(&filename, 1);

    // load AviSynth script
    AVSValue imported = se->Invoke("Import", args, 0);

    // get the clip and video info
    PClip clip = imported.AsClip();
    VideoInfo vi = clip->GetVideoInfo();

    cout << "*video status" << endl;
    cout << "HasVideo:            " << vi.HasVideo() << endl;
    cout << "IsRGB:               " << vi.IsRGB() << endl;
    cout << "IsRGB24:             " << vi.IsRGB24() << endl;
    cout << "IsRGB32:             " << vi.IsRGB32() << endl;
    cout << "IsYUV:               " << vi.IsYUV() << endl;
    cout << "IsYUY2:              " << vi.IsYUY2() << endl;
    cout << "IsYV12:              " << vi.IsYV12() << endl;
    cout << "IsPlanar:            " << vi.IsPlanar() << endl;
    cout << "IsFieldBased:        " << vi.IsFieldBased() << endl;
    cout << "IsParityKnown:       " << vi.IsParityKnown() << endl;
    cout << "IsBFF:               " << vi.IsBFF() << endl;
    cout << "IsTFF:               " << vi.IsTFF() << endl;
    cout << "RowSize:             " << vi.RowSize() << endl;
    cout << "BMPSize:             " << vi.BMPSize() << endl;

    cout << endl;
    cout << "*audio status" << endl;
    cout << "HasAudio:            " << vi.HasAudio() << endl;
    cout << "AudioChannels:       " << vi.AudioChannels() << endl;
    cout << "SampleType:          " << vi.SampleType() << endl;
    cout << "SamplesPerSecond:    " << vi.SamplesPerSecond() << endl;
    cout << "BytesPerAudioSample: " << vi.BytesPerAudioSample() << endl;

    return 0;
}