本文整理汇总了C++中VideoInfo::HasVideo方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoInfo::HasVideo方法的具体用法?C++ VideoInfo::HasVideo怎么用?C++ VideoInfo::HasVideo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoInfo
的用法示例。
在下文中一共展示了VideoInfo::HasVideo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, TCHAR* argv[]) {
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
printf("Usage: filmtester <avs filename> [duplicates_maxlength=2]\n");
printf("The program plays the AVS file and tests for frame duplicates\n\n");
int duplicates_maxlength = 2;
if (argc < 2) {
printf("No filename specified.\n\n");
return -1;
}
if (argc > 2) {
duplicates_maxlength = _ttoi(argv[2]);
printf("INFO: duplicates_maxlength set to %d\n", duplicates_maxlength);
}
IScriptEnvironment *env = CreateScriptEnvironment();
_tprintf(_T("Loading \"%s\" ...\n"), argv[1]);
LPCSTR arg_names[1] = { nullptr };
AVSValue arg_vals[1] = { (LPCSTR)argv[1] };
clip = env->Invoke("import", AVSValue(arg_vals,1), arg_names).AsClip();
printf("AVS file loaded successfully.\n\n");
VideoInfo vi = clip->GetVideoInfo();
printf("VideoInfo:\n");
printf("-----------\n");
if (vi.HasVideo()) {
printf("width x height: %dx%d\n", vi.width, vi.height);
printf("num_frames: %d\n", vi.num_frames);
printf("fps: %d/%d\n", vi.fps_numerator, vi.fps_denominator);
std::string colorspace;
if (vi.pixel_type & VideoInfo::CS_BGR) colorspace += "BGR, ";
if (vi.pixel_type & VideoInfo::CS_YUV) colorspace += "YUV, ";
if (vi.pixel_type & VideoInfo::CS_INTERLEAVED) colorspace += "INTERLEAVED, ";
if (vi.pixel_type & VideoInfo::CS_PLANAR) colorspace += "PLANAR, ";
if (colorspace.length() > 0) colorspace.erase(colorspace.length()-2);
printf("colorspace: %s\n", colorspace.c_str());
std::string colorformat;
if (vi.pixel_type & VideoInfo::CS_BGR24) colorformat += "BGR24, ";
if (vi.pixel_type & VideoInfo::CS_BGR32) colorformat += "BGR32, ";
if (vi.pixel_type & VideoInfo::CS_YUY2) colorformat += "YUY2, ";
if (vi.pixel_type & VideoInfo::CS_YV12) colorformat += "YV12, ";
if (vi.pixel_type & VideoInfo::CS_I420) colorformat += "I420 (IYUV), ";
if (colorformat.length() > 0)
colorformat.erase(colorformat.length()-2);
else
colorformat = "UNKNOWN";
printf("colorformat: %s\n", colorformat.c_str());
std::string imagetype;
if (vi.image_type & VideoInfo::IT_BFF) imagetype += "BFF, ";
if (vi.image_type & VideoInfo::IT_TFF) imagetype += "TFF, ";
if (vi.image_type & VideoInfo::IT_FIELDBASED) imagetype += "FIELDBASED, ";
if (imagetype.length() > 0)
imagetype.erase(imagetype.length()-2);
else
imagetype = "UNKNOWN";
printf("image_type: %s\n", imagetype.c_str());
printf("bits per pixel: %d\n", vi.BitsPerPixel());
}
else
printf("NO VIDEO\n");
if (vi.HasAudio()) {
printf("audio channels: %d\n", vi.nchannels);
printf("sample_type: %x\n", vi.sample_type);
printf("samples per second: %d\n", vi.audio_samples_per_second);
printf("bytes per channel sample: %d\n", vi.BytesPerChannelSample());
printf("bytes per audio sample: %d\n", vi.BytesPerAudioSample());
printf("num_audio_samples: %lld\n", vi.num_audio_samples);
}
else
printf("NO AUDIO\n");
printf("-----------\n\n");
if (!vi.HasVideo()) {
printf("Can't start video playback for the sequence without video.\n\n");
return -1;
}
printf("Starting playback ...\n");
prev_frame = clip->GetFrame(0, env);
int framesize = prev_frame->GetFrameBuffer()->GetDataSize();
printf("INFO: framesize = %d bytes.\n\n", framesize);
InitializeCriticalSection(&cs);
SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE);
int error_count = 0;
int dup_start_frame = 0;
bool flag_dup = false;
std::vector<std::pair<int, int>> duplicates;
for(int i=1; i<vi.num_frames; ++i) {
EnterCriticalSection(&cs);
dst = clip->GetFrame(i, env);
const BYTE *src_ptr = prev_frame->GetFrameBuffer()->GetReadPtr();
//.........这里部分代码省略.........
示例2: Output
int AvxContext::Output() {
if (vi.HasVideo()) // An Avisynth clip must have at least one stream.
return OutputVideo();
else
return OutputAudio();
}
示例3: dimzon_avs_init
int __stdcall dimzon_avs_init(SafeStruct** ppstr, char *func, char *arg, AVSDLLVideoInfo *vi)
{
SafeStruct* pstr = NULL;
if(!*ppstr)
{
pstr = ((SafeStruct*)malloc(sizeof(SafeStruct)));
*ppstr = pstr;
memset(pstr, 0, sizeof(SafeStruct));
pstr->dll = LoadLibrary("avisynth.dll");
if(!pstr->dll)
{
strncpy_s(pstr->err, ERRMSG_LEN, "Cannot load avisynth.dll", _TRUNCATE);
return 1;
}
IScriptEnvironment* (*CreateScriptEnvironment)(int version) = (IScriptEnvironment*(*)(int)) GetProcAddress(pstr->dll, "CreateScriptEnvironment");
if(!CreateScriptEnvironment)
{
strncpy_s(pstr->err, ERRMSG_LEN, "Cannot load CreateScriptEnvironment", _TRUNCATE);
return 2;
}
pstr->env = CreateScriptEnvironment(AVISYNTH_INTERFACE_VERSION);
if (pstr->env == NULL)
{
strncpy_s(pstr->err, ERRMSG_LEN, "Required Avisynth 2.5", _TRUNCATE);
return 3;
}
}
else
{
pstr = *ppstr;
}
pstr->err[0] = 0;
//Заходили только чтоб получить ppstr
if (!func || strlen(func) == 0 || !arg)
return 0;
try
{
AVSValue arg(arg);
AVSValue res;
if (vi != NULL && vi->mt_import == MT_DISABLED)
{
//Если надо, отключаем MT - до импорта
try { pstr->env->Invoke("SetMTMode", 0); }
catch (IScriptEnvironment::NotFound) { /*AviSynth без MT*/ }
}
res = pstr->env->Invoke(func, AVSValue(&arg, 1));
if(!*ppstr) return 1;
if (!res.IsClip())
{
strncpy_s(pstr->err, ERRMSG_LEN, "The script's return was not a video clip.", _TRUNCATE);
return 4;
}
if (vi != NULL && (vi->mt_import == MT_ADDDISTR || vi->mt_import == MT_ADDM1DISTR))
{
try
{
//Если надо, добавляем Distributor() - после импорта
AVSValue mt_test = pstr->env->Invoke("GetMTMode", false);
const int mt_mode = mt_test.IsInt() ? mt_test.AsInt() : 0;
if (mt_mode > 0 && mt_mode < 5)
{
if (mt_mode != 1 && vi->mt_import == MT_ADDM1DISTR)
pstr->env->Invoke("SetMTMode", 1);
res = pstr->env->Invoke("Distributor", res);
}
}
catch (IScriptEnvironment::NotFound) { /*AviSynth без MT*/ }
if (!res.IsClip())
{
strncpy_s(pstr->err, ERRMSG_LEN, "After adding \"Distributor()\" the script's return was not a video clip.", _TRUNCATE);
return 4;
}
}
pstr->clp = res.AsClip();
VideoInfo inf = pstr->clp->GetVideoInfo();
if (inf.HasVideo())
{
string filter = "";
string err_string = "";
//Original и Requested PixelType
if (vi != NULL) vi->pixel_type_orig = inf.pixel_type;
int pixel_type_req = (vi != NULL) ? vi->pixel_type : 0;
//.........这里部分代码省略.........