⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testgetinfo.m

📁 Video IO toolbox for matlab. 用directshow做的
💻 M
字号:
%testGetinfo
%  Script that does some minimal testing of the getinfo functions.  Windows
%  only.
%
%Example:
%  testGetinfo
%
%Copyright (c) 2006 Gerald Dalley
%See "MIT.txt" in the installation directory for licensing details (especially
%when using this library on GNU/Linux).

ienter

if ispc
  frames = rand(100,100, 10);

  try
    tmpDir = tempname; mkdir(tmpDir);

    iprintf('+------------------------------*');
    iprintf('| USER INTERACTION REQUIRED... |');
    iprintf('+------------------------------*');
    iprintf('Please select a codec and its parameters in the dialog that popped up (NOTE: you may need to use <ALT>-<TAB> to find the dialog)...\n');
    fname = fullfile(tmpDir, 'testGetinfoA.avi');
    vw = videoWriter(fname, 'plugin','DirectShow', 'showCompressionDialog',1);
    infoA = getinfo(vw);
    for i=1:size(frames,3), addframe(vw, frames(:,:,i)); end
    close(vw);
    dirA = dir(fname);
    a = fopen(fname);  dataA = fread(a, 'uint8');  fclose(a);

    iprintf('+------------------------------*');
    iprintf('| USER INTERACTION REQUIRED... |');
    iprintf('+------------------------------*');
    iprintf('Please choose a different codec and/or change at least one compression parameter (NOTE: you may need to use <ALT>-<TAB> to find the dialog)...\n');
    fname = fullfile(tmpDir, 'testGetinfoB.avi');
    vw = videoWriter(fname, 'plugin','DirectShow', 'showCompressionDialog',1);
    infoB = getinfo(vw);
    if strcmp(infoA.codecParams, infoB.codecParams)
      error('You were supposed to change either the codec and/or at least one compression parameter.');
    end
    for i=1:size(frames,3), addframe(vw, frames(:,:,i)); end
    close(vw);
    dirB = dir(fname);
    b = fopen(fname);  dataB = fread(b, 'uint8');  fclose(b);

    if dirA.bytes == dirB.bytes
      if all(a == b)
        error('The two files are identical.  Try adjusting the compression parameters more.');
      end
    end

    fname = fullfile(tmpDir, 'testGetinfoC.avi');
    vw = videoWriter(fname, 'plugin','DirectShow', 'codec',infoA.codec, 'codecParams',infoA.codecParams);
    infoC = getinfo(vw);
    for i=1:size(frames,3), addframe(vw, frames(:,:,i)); end
    close(vw);
    dirC = dir(fname);
    c = fopen(fname);  dataC = fread(c, 'uint8');  fclose(c);

    vrassert strcmp(infoA.codecParams, infoC.codecParams);
    vrassert dirA.bytes == dirC.bytes;
    vrassert all(dataA == dataC);

    rmdir(tmpDir, 's');
  catch
    e = lasterror;
    try close(vw); catch end
    rmdir(tmpDir, 's');
    rethrow(e);
  end
else
  iprintf('skipping testGetinfo on non-Windows boxes');
end

iexit

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -