C
#include "internal.h"
#include "windows.h"
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
if (argc != 2) {
return -1;
}
if (argc == 0) {
cerr << "usage: avsInfo \"Path to the .avs file\"" << endl;
return 0;
}
const char* infile = argv[1];
const char *dot = strrchr(infile, '.');
if (!dot || strcmp(".avs", dot)) {
cerr << infile << " is no .avs file" << endl;
}
try {
HMODULE avsdll = LoadLibrary(TEXT("avisynth.dll"));
if (!avsdll) {
cerr << "Couldn't find avisynth.dll!" << endl;
return -1;
}
IScriptEnvironment* (*CreateScriptEnvironment)(int version)
= (IScriptEnvironment*(*)(int)) GetProcAddress(avsdll, "CreateScriptEnvironment");
if (!CreateScriptEnvironment) {
cerr << "Couldn't create script environment!" << endl;
return -1;
}
IScriptEnvironment* env = CreateScriptEnvironment(AVISYNTH_INTERFACE_VERSION);
if (!env) {
cerr << "Couldn't create IScriptEnvironment!" << endl;
return -1;
}
AVSValue arg(infile);
AVSValue res = env->Invoke("Import", AVSValue(&arg, 1));
if (!res.IsClip()) {
cerr << "Found no valid avisynth clip!" << endl;
return -1;
}
PClip clip = res.AsClip();
VideoInfo inf = clip->GetVideoInfo();
if (!inf.HasVideo()) {
cerr << "Found no video info in current script!" << endl;
return -1;
}
cerr << "Color: ";
if (inf.IsYV12()) {
cerr << "Yv12";
} else if (inf.IsRGB()) {
cerr << "RGB";
} else if (inf.IsRGB24()) {
cerr << "RGB24";
} else if (inf.IsRGB32()) {
cerr << "RGB32";
} else if (inf.IsYUY2()) {
cerr << "YUY2";
} else if (inf.IsYUV()) {
cerr << "YUV";
} else {
cerr << "unknown" << endl;
}
cerr << ", Resolution: " << inf.width << "x" << inf.height;
if (inf.fps_denominator == 1) {
cerr << ", Frame rate: " << inf.fps_numerator << " fps";
} else {
cerr << ", Frame rate: " << inf.fps_numerator << "/" << inf.fps_denominator << " fps";
}
cerr << ", Length: " << inf.num_frames << " frames";
if (inf.IsBFF()) {
cerr << ", BFF" << endl;
} else if (inf.IsTFF()) {
cerr << ", TFF" << endl;
} else {
cerr << ", PRO" << endl;
}
if (inf.HasAudio()) {
int sampleRate = inf.audio_samples_per_second;
if (sampleRate != 0) {
cerr << "Audio:" << endl;
cerr << "Sample rate: " << sampleRate << " Hz";
cerr << ", Channel count: " << inf.nchannels << endl;
}
}
} catch (AvisynthError &err) {
cerr << "Avisynth error: " << err.msg << endl;
return -1;
}
return 0;
}
Alles anzeigen
Sobald ich avsInfo mit etwas füttere, was wirklich einen clip hat, beendet es sich nicht und mir ist nicht klar warum nicht.
Cu Selur
Ps.: Hab den Source auch mal angehängt