- MSYS2: http://www.msys2.org/
- pacman mirror: https://lug.ustc.edu.cn/wiki/mirrors/help/msys2
- pacman proxy: https://stackoverflow.com/questions/29783065/msys2-pacman-cant-update-packages-through-corporate-firewall
- FFmpeg: https://github.com/FFmpeg/FFmpeg
- MinGW/FFmpeg installation guide: https://trac.ffmpeg.org/wiki/CompilationGuide/MinGW
- VSCode: https://code.visualstudio.com/
- C/C++ for VSCode: https://code.visualstudio.com/docs/languages/cpp
- Using MinGW and Cygwin with Visual C++ and Open Folder: https://blogs.msdn.microsoft.com/vcblog/2017/07/19/using-mingw-and-cygwin-with-visual-cpp-and-open-folder/
a. download and install MSYS2 in default path
C:\msys64
b. set up pacman (msys2 package manager) mirror (Optional)
- edit /etc/pacman.d/mirrorlist.mingw32, add below line at the begining:
Server = http://mirrors.ustc.edu.cn/msys2/mingw/i686
- edit /etc/pacman.d/mirrorlist.mingw64, add below line at the begining:
Server = http://mirrors.ustc.edu.cn/msys2/mingw/x86_64
- edit /etc/pacman.d/mirrorlist.msys, add below line at the begining:
Server = http://mirrors.ustc.edu.cn/msys2/msys/$arch
c. set up pacman proxy (Optional)
- open file: C:\msys64\etc\profile
- add below lines at the end of file
export http_proxy=<myusername>:<mypassword>@proxy-host-name:8080
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export socks_proxy=$http_proxy
export rsync_proxy=$http_proxy
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
- note 1: myusername and mypassword can be optional
- note 2: example of proxy-host-name: http://xxx.xxx.com
pacman -S -y -u
or
pacman -Syu
pacman -S git
pacman -S make diffutils nasm yasm
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-i686-gcc
a. download and install vscode from this link
C/C++
Code Outline
Code Navigation
vscode-icons
cd c:\msys64
mingw64.exe
b. get ffmpeg source code
cd ~
git clone https://github.com/FFmpeg/FFmpeg.git
cd ~/FFmpeg
./configure --enable-debug=3 --disable-optimizations
make -j8
build x264/x265 with ffmpeg
sudo apt install libx264-dev libx265-dev
cd ~/FFmpeg
./configure --enable-debug=3 --disable-optimizations --enable-libx264 --enable-libx265 --enable-gpl
make -j8
ffmpeg_g.exe
ffmpeg.exe
ffprobe_g.exe
ffprobe.exe
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/ffmpeg_g.exe",
"args": [
"-hwaccel",
"dxva2",
"-i",
"test.mp4",
"tmp.yuv",
"-y"
],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
}
]
}
- switch vscode to debug pannel and click Start Debugging button
- ffmpeg will break at entry of main() function
- set a break point at ff_dxva2_common_end_frame in dxva2.c
int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
const void *pp, unsigned pp_size,
const void *qm, unsigned qm_size,
int (*commit_bs_si)(AVCodecContext *,
DECODER_BUFFER_DESC *bs,
DECODER_BUFFER_DESC *slice))
{
// ...
#if CONFIG_D3D11VA
if (ff_dxva2_is_d3d11(avctx))
hr = ID3D11VideoContext_SubmitDecoderBuffers(D3D11VA_CONTEXT(ctx)->video_context,
D3D11VA_CONTEXT(ctx)->decoder,
buffer_count, buffer11);
#endif
#if CONFIG_DXVA2
if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
DXVA2_DecodeExecuteParams exec = {
.NumCompBuffers = buffer_count,
.pCompressedBuffers = buffer2,
.pExtensionData = NULL,
};
hr = IDirectXVideoDecoder_Execute(DXVA2_CONTEXT(ctx)->decoder, &exec);
}
#endif
if (FAILED(hr)) {
av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%x\n", (unsigned)hr);
result = -1;
}
}