WIN10 compile ffmpeg (including ffplay)

1. Install MSYS2

       Win10 builds MSYS2 environment - Programmer Sought

2. Compile SDL

        SDL is the basis for compiling and generating ffplay. It is not necessary to generate ffplay without compiling SDL.

        1) Download address: https://www.libsdl.org/download-2.0.php

        2) Since it is compiled under MSYS2, download the package SDL2-2.0.22.tar.gz  -  GPG signed . (Put SDL2-2.22.tar.gz.sig in the decompression directory of SDL2-2.22.tar.gz)

        3) Compilation steps

              step1, mkdir /usr/local/SDL2 This path is used to store SDL compiled files, which can be changed (after the change, other places will also be modified simultaneously)

              Step2. Enter the decompression directory of SDL2-2.22.tar.gz, and execute ./configure --prefix=$MSYS2/usr/local/SDL2/ where $MSYS2 represents your own MSYS2 installation directory (modified according to your own situation).

              step3、make

              step4、 make install

              After the compilation is successful, it will be in the corresponding library directory in $MSYS2/usr/local/SDL2/ (if it is not generated, you need to carefully check whether there is an error in the above three steps):

        4) An error was reported during the recording compilation process , which was encountered in both SDL2-2.0.18 and SDL2-2.0.22 versions. The make step compiles SDL_windows_gaming_input.c, and the error message is as follows:

        make: *** [makefile:730: build/sdl_windows_gaming_input.lo] error 1

        Here it should be that the definition type of windows is different from that of linux. You need to modify the SDL_windows_gaming_input.c ($MSYS2/home/source/SDL2-2.0.18/src/joystick/windows) file and add a new macro (here is a reference to SDL issue Solved, the path is pasted at the end). The modification is as follows:

//增加宏
#ifdef __MINGW32__
#define __FIReference_1_int __FIReference_1_INT32
#define __FIReference_1_int_get_Value __FIReference_1_INT32_get_Value
#define __FIReference_1_int_Release __FIReference_1_INT32_Release
#endif

//源代码
struct joystick_hwdata
{
    __x_ABI_CWindows_CGaming_CInput_CIRawGameController *controller;
    __x_ABI_CWindows_CGaming_CInput_CIGameController *gamecontroller;
    __x_ABI_CWindows_CGaming_CInput_CIGameControllerBatteryInfo *battery;
    __x_ABI_CWindows_CGaming_CInput_CIGamepad *gamepad;
    __x_ABI_CWindows_CGaming_CInput_CGamepadVibration vibration;
    UINT64 timestamp;
};

3. Compile ffmpeg        

    1), need to configure the environment

        Execute the command in the mingw64 command window:

1、Pacman -S nasm

2、Pacman -S yasm

3、Pacman -S make cmake

4、 Pacman -S diffutils

    2), set the library directory of SDL2

        export PATH="/usr/local/SDL2/bin/:$PATH"     

   3), ffmpeg compilation instructions

1、./configure --enable-shared --disable-static --enable-debug --enable-sdl2 --extra-cflags='-I/usr/local/SDL2/include/SDL2/' --extra-ldflags='-L/usr/local/SDL2/lib/' --prefix=/home/source/ffmpeg_build/

2、make

3、make install

The library files generated after successful compilation are in the /home/source/ffmpeg_build/ directory.

4. Reference articles

Compile and debug ffmpeg under Windows, including ffplay_shizheng163's blog - CSDN blog

compilability of WGI code against MinGW headers · Issue #5589 · libsdl-org/SDL (github.com)

FFmpeg: compile (Windows)

Guess you like

Origin blog.csdn.net/yq327115059/article/details/125954717
Recommended