1. Install MinGW
1.1. Download MinGW
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:
1.3. Click "Install" directly to enter the following dialog box
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:
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:
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:
1.7. After the installation is completed, we need to manually configure the PATH environment variable
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:
2. Install msys2
2.1. Download msys2
2.2. Double-click to run .exe
2.3. Click "Next"
2.4. After completion, click "Finish"
2.5. Enter the installation directory and execute .\msys2_shell.cmd -mingw64
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
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.
3.2. Download FFmpeg
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
- Be sure to replace "" in the windows path with "/"
3.4. Enter the ffmpeg-4.4.4 directory
3.5. ./configure --help to view compilation configurable parameters
-
–prefix configure installation path parameters
-
Configure cross-compilation parameters
-
Configuration does not require generating related tools
3.6. Execute configure
- Use ""+enter to enter multi-line parameters in a new line
3.7. Execute make -j8
3.8. Execute make install
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