Recently, network video applications need to be developed. Because videos need to be encoded, select H. 264 encoding, found the x264 library from the internet for use, but unfortunately this library is in Linux, but our applications need to be deployed on Windows systems, therefore, I can only compile it into a dynamic link library for use. I have found many methods from the Internet, but they are not very useful. As a result, I have always encountered problems, here, I will record my own configuration process.
The mingw compilation method I use
First download mingw from the Internet.
After installation, the installation is online and takes some time. At this time, we can download other required tools.
Download the source code of x264 from the official x264 website.
Next, add mingw to the environment variable. Otherwise, a problem may occur. You can use the command line or set it directly on the interface. Run the following command line: Open CMD and enter setx msys_homec:/mingw/bin. Make sure to set the directory address to the location of your mingw installation folder. Alternatively, right-click computer> Properties> advanced system Settings> environment variables to add a new one.
In this case, run msys/1.0/msys. bat in the mingw folder, and then you can see the interface shown in. Switch to the directory where the x264 source code is located through the command line.
Enter. /configure -- enable-shared can succeed without accident. Then, enter make and download a tool to export DLL to Lib, which is named poxports, download link: Workshop:
Pexports D: \ libx264-120.dll> D: \ libx264-120.def
Open cmd, switch to the directory where the source code is x264, and enter the following command: (to execute this command, make sure that vs2008 or vs2010 vs tools is installed on the machine)
LIB/machine: x86/DEF: libx264-132.def/out: libx264-32.lib
Then you can export libx264-132.dll and libx264-32.lib
Create a project with vs, place the libx264-132.dll and libx264-32.lib under the project directory,
Copy x264.h and x26_config.h from the x264 folder to the project directory and add them to the project,
Add the Lib Library to the Project Settings. Compile and run, OK. The running process may prompt that pthreadgc2.dll is missing,
Download one from the Internet.
# Include <iostream>
# Include <string>
# Include "stdint. H"
Extern "C"
{
# Include "x264.h"
# Include "x264_config.h"
};
Using namespace STD;
Int main ()
{
X1__param_t Param;
X1__param_default (& PARAM );
Return 0;
}
I think this library can be compiled and used directly. You don't need to compile it yourself,
I have packaged my own compiled results, but today I cannot upload them to csdn. If necessary, I can leave my mailbox,
Send your email directly after I see it. After that, I can upload the file directly.
I don't know how to use this library. I will update the programming method after learning it.
I uploaded this library and the compiled FFMPEG library to my GitHub. Click here.