ffmpeg windows environment MinGW+msys2 compile so library

1. Install MinGW

1.1. Download MinGW

Insert image description here

1.2. After the download is completed, you will get an installation package named mingw-get-setup.exe. Double-click it to open it and you will see the following dialog box:

Insert image description here

1.3. Click "Install" directly to enter the following dialog box

Insert image description here

1.4. You can customize the installation location of MinGW according to the actual situation of your own operating system (for example, I chose to install it to the E drive), and then click "continue" to enter the following dialog box:

Insert image description here

1.5. Enter the interface for installing the MinGW configurator. Readers can wait patiently for the installation to complete (displaying 100%). After the installation is complete, we will get a software called "MinGW Installer Manager", with which we can modify the configuration of the GCC compiler at any time as needed. Click "continue" and the configuration interface will automatically pop up, as shown below:

Insert image description here

1.6. In order for GCC to support compiling C language and C++ at the same time, you need to check the two items marked in the figure. After the check is completed, select Installation -> Apply Changes in the menu bar, and the following dialog box will pop up:

Insert image description here

1.7. After the installation is completed, we need to manually configure the PATH environment variable

Insert image description here

1.8. Open the command line window (just execute the cmd command in the search bar) and enter the gcc -v command. If the specific information of the GCC compiler is output, it means the installation is successful, for example:

Insert image description here

2. Install msys2

2.1. Download msys2

Insert image description here
Insert image description here

2.2. Double-click to run .exe

Insert image description here

2.3. Click "Next"

Insert image description here

2.4. After completion, click "Finish"

Insert image description here

2.5. Enter the installation directory and execute .\msys2_shell.cmd -mingw64

Insert image description here
Insert image description here

2.6. Use pacman to install the tools needed to compile FFmpeg.

pacman -S  mingw-w64-x86_64-toolchain git make automake  autoconf perl libtool mingw-w64-x86_64-cmake pkg-config yasm diffutils nasm

Insert image description here

3. Compile FFmpeg

3.1. Find the folder named after your own windows user name in the home folder of msys2 and create ffmpeg, because only the files created here can be recognized by msys2.

Insert image description here

3.2. Download FFmpeg

Insert image description here

3.3. Set environment variables for cross-compilation

export PATH=$PATH:/d/Android\AndroidStudio/SDK/ndk/23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin

Insert image description here

  • Be sure to replace "" in the windows path with "/"

3.4. Enter the ffmpeg-4.4.4 directory

Insert image description here

3.5. ./configure --help to view compilation configurable parameters

Insert image description here

  • –prefix configure installation path parameters
    Insert image description here

  • Configure cross-compilation parameters
    Insert image description here

  • Configuration does not require generating related tools
    Insert image description here

3.6. Execute configure

Insert image description here

  • Use ""+enter to enter multi-line parameters in a new line
    Supported decoding
    Supported encodings

3.7. Execute make -j8

Insert image description here

3.8. Execute make install

Insert image description here
Insert image description here

3.9. Compile armv7-a

$ ./configure \
--prefix=/home/company/ffmpeg/armv7-a \
--target-os=android \
--arch=arm  \
--cpu=armv7-a \
--cc=clang \
--cxx=clang++ \
--strip=llvm-strip \
--extra-cflags="--target=armv7a-linux-androideabi27" \
--extra-ldflags="--target=armv7a-linux-androideabi27" \
--extra-cflags="-Os -fpic -march=armv7-a" \
--disable-asm \
--disable-stripping \
--disable-doc \
--disable-ffplay \
--disable-ffprobe \
--disable-symver \
--disable-ffmpeg \
--enable-neon \
--enable-cross-compile \
--enable-shared

Guess you like

Origin blog.csdn.net/u011557841/article/details/132492445
Recommended