Sunday, June 21, 2009

How to compile Media Player Classic using Visual Studio 2005

Getting Media Player Classic (MPC) compiled correctly involves various downloads and setups. It really took me few nights (late late nights) to make it build right using VS2005. I put up the steps on how to make it compile right and hope it can benefit people who find MPC worth while do not need to suffer what I've been through.

My system is XP SP3 but the steps to make it built correctly should be similar.

Steps to build Media Player Classic v6.4.9.0 using Visual Studio 2005:
1. Install the following:
a. Platform SDK 6.1.
- Download from here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=e6e1c3df-a74f-4207-8586-711ebe331cdc&displaylang=en
- The default installation path:
C:\Program Files\Microsoft SDKs\Windows\v6.1

b. DirectX SDK from June 2007 (the last version that has DirectX 7 SDK).
- Download from here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=371f6ba4-2737-46ab-b275-0dcab31459b5&displaylang=en
- Extract the files using WinRAR. Copy the dxsdk to the following path:
C:\Program Files\Microsoft SDKs\Windows\dxsdk_jun2007

2. Add the following path to VS2005 (in this particular order) in front of all other path settings.
a. Include path:
- C:\Program Files\Microsoft SDKs\Windows\v6.1\Samples\Multimedia\DirectShow\BaseClasses
- C:\Program Files\Microsoft SDKs\Windows\dxsdk_jun2007\Include
- C:\Program Files\Microsoft SDKs\Windows\v6.1\Include
b. Library path:
- C:\Program Files\Microsoft SDKs\Windows\dxsdk_jun2007\Lib\x86
- C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib

3. All projects should be using Unicode configuration for building projects. There are 3 main projects:
a. BaseClasses (from Platform SDK)
- Use "Debug" configuration
b. Filters (from MediaPlayerClassic source code)
- Use "Debug Unicode Lib" configuration
c. mplayerc (from MediaPlayerClassic source code
- Use "Debug Unicode" configuration

4. Build BaseClasses project in "C:\Program Files\Microsoft SDKs\Windows\v6.1\Samples\Multimedia\DirectShow\BaseClasses"
a. Need to change the following configurations. Or it will have __wargv & __argc link error when building mplayerc.
- In C/C++ Code Generation, change RunTime Library from "MultiThreaded Dubug DLL" to "MultiThreaded Debug"
b. Make sure building the project using "Debug" configuration.
c. Once built, copy "strmbasd.lib" in "Debug" folder to "guliverkli\trunk\guliverkli\lib" folder.
- Rename "strmbasd.lib" to "StrmBaseDU.lib" after copying.

5. Build "filter" project in "guliverkli\trunk\guliverkli\src\filters"
a. Prepare the code for AP4 in "guliverkli\trunk\guliverkli\src\filters\parser\mp4splitter\AP4"
- Extract the "Bento4_0.6.3-001.7z" in folder "guliverkli\trunk\guliverkli\src\filters\parser\mp4splitter\AP4\Update\v0.6.3"
- Copy the content of "Source" folder of "Bento4_0.6.3-001.7z" to "guliverkli\trunk\guliverkli\src\filters\parser\mp4splitter\AP4"
- Override the files in "Config", "Core", and "Crypto" in "mp4splitter\AP4\Update\v0.6.3\Source" folders to the folders in "mp4splitter\AP4\Source"
b. Update BaseClasses project path to point to "Windows\6.1". This is to use BaseClasses in Windows 6.1 SDK.
- Open "filters_vs2005.sln" using any text editor. Find the word "BaseClasses" and change the "v6.0" in path to "v6.1".
c. Correct the code in "CDecoder.cpp".
- Find the word "charmap" in CCDecoder::DecodeCC(). In "charmap" array, make sure every '?' has a closing single quote.
d. Remark out VP62.h in "guliverkli\trunk\guliverkli\src\filters\parser\flvsplitter\flvsplitter.h"
- Find "VP62.h" in "flvsplitter.h". Remark out the entire line #include "VP62.h"
- In project "FLVSplitter", remove the file "Source --> VP62.cpp".
e. Open the "filter" project and build the code.
- You can safely ignore "RadGTSplitter" warning when opening the project.
- Make sure building the project using "Debug Unicode lib" configuration.

6. Build "mplayerc" project in "guliverkli\trunk\guliverkli\src\apps\mplayerc"
a. Update BaseClasses project path to point to "Windows\6.1". This is to use BaseClasses in Windows 6.1 SDK.
- Open "mplayerc_vs2005.sln" using any text editor. Find the word "BaseClasses" and change the "v6.0" in path to "v6.1".
b. Open the "mplayerc" project.
c. In project "mplayerc", remove the file "temp --> SubmitNotPlayFileDlg.cpp".
d. Need to change the following configurations. Or it will have __wargv & __argc link error when building mplayerc.
- In C/C++ Code Generation, change RunTime Library from "MultiThreaded Dubug DLL" to "MultiThreaded Debug"
e. make sure building the project using "Debug Unicode" configuration"

7. Run/Debug mplayerc and enjoy!


1 comment: