Why compile FFmpeg on Windows
FFmpeg is a MakeFile project for Linux environment.
while on Windows
1 If you just use it, the most convenient way is to download FFmpeg.exe compiled by others and use it directly on the cmd command line.
2 If you want to compile and use it yourself, the most convenient way is to compile and use it in WSL.
3 Compile ffmpeg.exe ffmpeg.pdb with MSYS2 on Windows, and directly create a project for debugging.
need
In order to understand the principle of FFmpeg, read comprehension and explore its source code implementation, it is necessary to debug FFmpeg in the Windows environment.
FFmpeg source code official download
Index of /releases Download FFmpeg
Linux compilation environment on Windows
Compile ffmpeg libs on Windows with Visual Studio compiler (Marco Pracucci)
msys2
Tsinghua mirror to download the latest version of msys2: msys2 | mirror station use help | Tsinghua University open source software mirror station | Tsinghua Open Source Mirror
The default path can be installed: C:\msys64
After installation, there is a shortcut on the desktop, open it
This window means that msys is actually a Linux subsystem. Actually this console is:
There are actually several other versions:
Install tools in this subsystem:
$ pacman -S make gcc diffutils
The picture above is a screenshot after executing the following command first. Installed the three software make gcc diffutils into msys2.
Open the MinGW of msys2 using the command line of vs2022
msys2_shell.cmd -mingw64
The figure above shows that although msys2 is opened from the command line of vs2022, cl.exe and link.exe are still not found
Make sure that a version of cl.exe link.exe of your vs2022 can find:
export PATH=${PATH}:/C/'Program Files'/'Microsoft Visual Studio'/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64
Try again which cl ; which link;
Use msys2 to switch to the FFmpeg code directory and execute the configuration:
./configure --toolchain=msvc --arch=x86 --enable-asm --enable-shared --disable-static --disable-x86asm
make
Debugging FFmpeg using VisualStudio under Windows - Programmer Sought
After all the above processes are completed, FFmpeg.exe ffmpeg_g.exe and the corresponding pdb files will be generated.
With the pdb file we can debug FFmpeg.
The specific operation is as follows:
Configure VisualStudio project, debug ffmpeg
(1) Create a new empty project and set the project properties as follows
Among them, the command parameter -i C:\testinput.mp4 -yc:\output.mp4 means to convert the testinput.mp4 file under the c drive to the output.mp4 file under the c drive, so you need to prepare a testinput.mp4 file yourself to the root directory of the c drive
(2) Add the fftools/ffmpeg.c file to this project, and add a breakpoint in the main function:
(3) Click F5 to run the debugging, and it will prompt that there is a compilation error. Whether to continue running on the last successful compilation result, select "Yes". Then you can break at the breakpoint.
Let's enjoy the rest of the process by ourselves.
Download x264 x264, the best H.264/AVC encoder - VideoLAN
Original FFmpeg Windows compilation and debugging
★The business card at the end of the article can receive free audio and video development learning materials, including (FFmpeg, webRTC, rtmp, hls, rtsp, ffplay, srs) and audio and video learning roadmaps, etc.
see below!