4. How to compile and run testing files utilizing FFMPEG in VC?
1. Create a new console application ("File / New / Project") and then select "Win32 Console Application". On the appropriate page of the Application Wizard, uncheck the "Precompiled headers" option.
2. Write the source code for your application, or, for testing, just copy the code from an existing sample application into the source file that VC has already created for you. For example, you can copy `output_example.c' from the FFmpeg distribution.
3. Open the "Project / Properties" dialog box. In the "Configuration" combo box, select "All Configurations" so that the changes you make will affect both debug and release builds. In the tree view on the left hand side, select "C/C++ / General", then edit the "Additional Include Directories" setting to contain the path where the FFMPEG is installed. Please refer Figure 4-1, and the“C:/Source Code/ffmpeg” is used in this instance.
Figure 4-1 Additional Include Directories
4. Still in the "Project / Properties" dialog box, select "Linker / General" from the tree view and edit the "Additional Library Directories" setting to contain the `lib' directory where FFMPEG was installed(referring Figure 4-2). Then select "Linker / Input" from the tree view, and add the files ‘avcodec-52.lib avdevice-52.lib avformat-52.lib avutil-49.lib’ to the end of "Additional Dependencies". Please refer to Figure 4-3.
Figure 4-2 Additional Library Directories
Figure 4-3 Additional Dependencies
5. Now, select "C/C++ / Code Generation" from the tree view. Select "Debug" in the "Configuration" combo box. Make sure that "Runtime Library" is set to "Multi-threaded Debug DLL". Then, select "Release" in the "Configuration" combo box and make sure that "Runtime Library" is set to "Multi-threaded DLL".
6. Click "OK" to close the "Project / Properties" dialog box.
7. VC lacks some C99 header files that are fundamental for FFMPEG. Get msinttypes from msinttypes-r21.zip and extract it in VC's include directory (i.e. ` C:/Program Files/Microsoft Visual Studio 8/VC/include ').
8. VC also does not understand the inline keyword used by FFMPEG, so you must add this line before #includeing libav*. Moreover, some functions, such as snprintf etc, must be added ‘_’ before initial character. For instance, changing snprintf to _snprintf.
#define inline _inline |
9. Compile the testing files and copy ‘avcodec-52.dll avdevice-52.dll avformat-52.dll avutil-49.dll’ into folder encapsulating executable file after building completely, and then run it.