Windows compiles ffmpeg and opens the png codec

Not much nonsense, first upload the download link

ffmpeg official website: http://ffmpeg.org/download.html

ffmpeg source download link: https://ffmpeg.org/releases/ffmpeg-3.4.13.tar.gz

If you need other versions, just modify the version number, which is applicable to the whole series of 3.4, such as https://ffmpeg.org/releases/ffmpeg-3.4.8.tar.gz

Compiling ffmpeg on windows requires mingw environment support. For specific tutorials, check my blog post:

[Untitled] Use cmake to compile c++ under windows_Di Lite's Blog-CSDN Blog

The following are shell commands executed within the mingw environment:

#定位到代码根目录
cd /e/workspace/ffmpeg-3.4.13
#配置cmake
./configure --prefix=build --arch=x86_64 --enable-shared --enable-static --disable-ffserver --enable-ffplay --disable-debug --disable-doc


make clean

make -j4

make install

After compiling, copy the contents of the build directory to the directory to be installed (not necessary). Also set environment variables (required):

After the environment variables are configured, use the command to test whether the function is normal:

 

It should be noted that because the windows platform does not have libpng.dll by default, the default packaged ffmpeg does not have a png encoder and decoder, so after we compile ffmpeg, if we want to import or export png format, the following error will appear:


 

 Next, we start the routine stepping on c++. . . These all need to be compiled in the msys environment of mingw64

Add to explain how to solve the problem of encoder for format image2 (codec png) is probably disabled. in the linux environment. Just install one of the following software before installation

 sudo apt install libopencv-dev
#opencv的开发包里有包含libpng-tools,按需要安装即可
 sudo apt install libpng-tools

Now that we know that libpng is needed to correctly export and import png format, then we go to the official website of libpng to download and compile. However, libpng also needs the support of zlib to work properly. Here we no longer guide writing, just follow the order, link, and plan. If there is no need for compilation support, as long as the dll is required, the dll can be obtained directly from Tencent's programs, such as qq, tim, WeChat, etc. No need to compile. So here comes the problem. Why do we compile. It's because we need static libraries.

Here are 2 options for you to choose from:

Option One:

Lazy people directly link to download the mingw64 that I have configured. You only need to modify the mingw64 directory corresponding to msys in the blog post to the directory you actually saved. At the same time, you need to configure your mingw64 in the environment variable.

[Untitled] Use cmake to compile c++ under windows_Di Lite's Blog-CSDN Blog

Option II:

zlib download link http://www.zlib.net/

cd /e/workspace/zlib-1.2.13/
make -f win32/Makefile.gcc

After the compilation is complete, copy the entire required file to the corresponding directory, as explained in the gcc file above, check it yourself.

Generally speaking, compiling zlib went smoothly, almost once, and the next libpng has more headaches.

First of all, there is a problem with the official download link. The official provides zip and gzip packages. There is a problem with the zip package, and you will encounter errors one by one. options.awk:bad line (10): com

 When I encountered this problem, I thought at first that it would be enough to install awk support, but it didn't work, so what should I do? After checking relevant information on Google, I accidentally found that the official gzip package can be compiled normally, but after configuration, there is an error in libpngconf.h when making make. This error is also very simple. Just put The code with newlines in the definition can be changed to no newlines. For the sake of the article, I sacrificed a bit, found a temporary directory, and compiled libpng again.

The official address of libpng: http://www.libpng.org/pub/png/libpng.html

Download link of libpng: https://download.sourceforge.net/libpng/libpng-1.6.39.tar.gz

cd /e/workspace/libpng-1.6.39/
./configure --prefix=e:/workspace/libpng-1.6.39/build --enable-shared --enable-static
make clean
make -j8
make install
#拷贝libpng的目录内容到mingw的根目录

Start compilation:

 Error encountered using tar.gz package: pnglibconf.h:206:54: error: expected identifier or '(' before '-' token

Let's go to line 206 of pnglibconf.h to see the problem:

 

 We saw that the code was inexplicably wrapped, well, we found the problem and fixed it.

The repaired code is as shown below:

 compile successfully

Compiled results:

​ 

Just copy the contents of the entire build to the root directory of mingw64. Note that after copying, you need to restart the mingw window.

Lazy direct link libpng achievement package:  https://download.csdn.net/download/DeleteElf/87910669

Guess you like

Origin blog.csdn.net/DeleteElf/article/details/131222799