This file describes how to set up the videoIO toolbox on a 32-bit or 64-bit Windows platform. See README.txt for a more general description of this library and tips on using it. See INSTALL.ffmpeg.txt for GNU/Linux installation instructions.
If you are (a) using Windows XP, Windows Server 2003, or Windows Vista, (b) using Matlab 2007a or later, and (c) have downloaded a videoIO package that already includes prepackaged binary .mex* files, you may skip to the Matlab Path section. If you experience any problems running the basic tests or if you wish to build the library from its source, read this whole document. You must download the full videoIO package to build the library from source. If you downloaded a .zip file with "Bin" in its name, you have the wrong .zip file.
If you do not know what environment variables are or how to permanently change them in Windows, see FAQ.txt.
In the instructions below,
Alternatively, return to the prerequisites section of this document and select the configuration options you'll be using. If you use an HTML4-compatible browser with JavaScript enabled, this document will self-customize to your configuration.
In these instructions, some directories will need to be added to various environment variables. Many of these folders will not exist until later in the instructions; however, we will modify all of the environment variables now. This makes the installation process faster and less complex.
Create the "INCLUDE" system environment variable (if it does not already exist) and add the following paths to it.
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Samples\Multimedia\DirectShow\BaseClasses C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include C:\Program Files\Microsoft SDKs\Windows\v6.1\Samples\Multimedia\DirectShow\BaseClasses C:\Program Files\Microsoft SDKs\Windows\v6.1\Include %DXSDK_DIR%\Include
When using path-like environment variables on Windows, place a semicolon between each string. For example, if the current INCLUDE variable is "C:\foo" and you wish to add "C:\bar\baz", the new INCLUDE variable will be "C:\foo;C:\bar\baz" (without quotes). It is important to have no extra spaces before or after the semicolons. We have placed each path on a separate line in this document for readability purposes.
Note: DXSDK_DIR is an environment variable which will be created when the DirectX SDK is installed.
It's important that the include directories be in the order given above (i.e. the BaseClasses directory must appear before the base SDK's Include, and that before the DirectX's Include). Microsoft likes to create stub headers (.h files) with the same names as the real ones and if the stubs are found first, they break the compilation.
Add the following strings to the "LIB32" system environment variable (you may skip this if you are using 64-bit Matlab only):
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Samples\Multimedia\DirectShow\BaseClasses\WIN2000_RETAIL C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib C:\Program Files\Microsoft SDKs\Windows\v6.1\Samples\Multimedia\DirectShow\BaseClasses\Release C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib\x86 C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib
Order is important here too.
Add the following strings to the "LIB64" system environment variable (you may skip this if you are using 32-bit Windows):
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Samples\Multimedia\DirectShow\BaseClasses\WIN2000_RETAIL C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib C:\Program Files\Microsoft SDKs\Windows\v6.1\Samples\Multimedia\DirectShow\BaseClasses\x64\Release C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib\x64 C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib
Order is important here too.
Add the appropriate one of the following strings to the "PATH" system environment variable (remember to omit " (x86)" if you are using 32-bit Windows).
C:\Program Files (x86)\Microsoft Visual Studio 7\VC\bin C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin C:\Program Files (x86)\Microsoft Visual Studio 9\VC\bin
As of Oct. 2007, this patch must be manually downloaded and installed. It is not pushed through Windows Update. When service pack 1 is released, this (or an equivalent patch) is expected to be included.
As far as the authors know, all versions of XP work with this software, though we naturally recommend that users regularly update their system using Windows Update to avoid security risks.
First, install Visual Studio:
Microsoft Visual Studio 2005 Professional → Language Tools → Visual C++ → X64 Compilers and ToolsYou may uncheck all .NET and all non C++ options if you want to save space and installation time. If you get an Vista incompatibility warning, ignore it and tell Vista to run the program anyway.
Now, we get to configure Visual Studio so it can find the SDKs we'll be installing. As was the case with the environment variables, it's easier to do it all at the same time, so we'll do it now. In Visual Studio, go to
Tools → Options... → Projects and Solutions → VC++ Directoriesthen
Then using the menus,C:\Program Files\Microsoft SDKs\Windows\v6.1\Samples\Multimedia\DirectShow\BaseClasses\baseclasses.sln
cflags=$(cflags) /Zc:wchar_t-as a new line after the !include <win32.mak> line. This forces the same character data type definitions that Matlab requires.
set PATH="%PATH%;C:\Program Files\Microsoft Visual Studio 8\VC\bin" cd "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Samples\Multimedia\DirectShow\BaseClasses" "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" set LIB=%LIB%;%LIB32% nmake NODEBUG=1 _CRT_SECURE_NO_DEPRECATE=1
If you are using a version of Visual Studio other than 2005 and/or if you are using a 64-bit operating system, adjust the aboves paths as appropriate.
If you're building 64-bit versions, you will most likely need to add "amd64" as a command-line argument to "vcvarsall.bat" and change "set LIB=%LIB%;%LIB32%" to "set LIB=%LIB%;%LIB64%". This is untested.
If you are using Visual Studio 2003, use vcvars32.bat instead of vcvarsall.bat.
C:\Program Files (x86)\Microsoft DirectX SDK (August 2008)
(modify this directory to point to your SDK's base directory).
Follow the on-screen instructions. If you have multiple compilers installed, choose the one that was configured in the Visual Studio section of this document.mex -setup
replacing "R2007b" with your Matlab revision.%APPDATA%\MathWorks\MATLAB\R2007b\mexopts.bat
This eliminates a number of spurious warning messages.-D_CRT_SECURE_NO_DEPRECATE
This provides proper treatment of the character data type./Zc:wchar_t-
This adds VS2003 exception support./EHsc
This fixes a VS2003 duplicate-linkage problem./NODEFAULTLIB:LIBCMT.LIB
to the beginning of the list (it's at the end by default). This corrects for some interface changes Microsoft has made to its SDKs. Make sure there's a semicolon between "%INCLUDE%" and the next entry in the list.%INCLUDE%
to the end of the line (with no whitespace).;%LIB32%
to the end of the line (with no whitespace).;%LIB64%
If the build fails, recheck that you followed all of the previous instructions in this file exactly. You may also want to look at the FAQ for solutions to common problems.buildVideoIO
File → Set Path... → Add Folder...Alternatively, from the Matlab command line this can be done using the "addpath" and "savepath" functions.
Do not add directories recursively: the @videoReader/, @videoWriter/, and private/ directories are handled automatically by Matlab's object system. The tests/ subdirectory contains files that are essentially private (e.g. a function named testAll could easily appear in other toolboxes or in the user's own code).
In Matlab, go to the tests/ subdirectory and run testAll:
% if this fails, you forgot to add the videoIO directory to your matlab path. cd(fullfile(videoIODir, 'tests')); % This will take a long time (perhaps up to a few hours) to complete, but the % most basic and most critical tests are run first. testAll
help buildVideoIO help videoReader help videoWriter help videoread
Also consider looking at tests/videoWriterDemo.m and tests/addFrameDemo.m for examples of writing videos.