compile FFMPEG under windows

这个文章应该算是中文版最好的了。但是还有一些需要修正。 特别是winsock2的处理

win10 msys2 vs2015 ffmpeg3.2.2 编译

这个英文版的才是最好的

Building ffmpeg 3.3 with MSYS2 + MSVC 2017 failed with so many winsock2 related redefinitions

MSYS2 + Visual Studio 2017 Community here, the exact steps I take to build are:
1. Start a Visual Studio 2017 "Developer Command Prompt", which effectively run vcvars.bat
2. cd into msys64 directory, and then invoke MSYS2 within the command prompt with "msys2_shell.cmd -msys2 -use-full-path", which make msys2 inherited the envs set by vcvars
3. In MSYS2 shell, cd into /somewhere/ffmpeg-build/
4. rm -rf *
5. run "../ffmpeg-3.3/configure --prefix=/somewhre/to/install/ffmpeg-bin --toolchain=msvc" in the build folder. configure script complete successfully.
6. make 

and then during the build, after about half done, so many winsocks2 functions related redefinition fail the build.
And I've found an easy fix, that is "../ffmpeg-3.3/configure --prefix=/somewhre/to/install/ffmpeg-bin --toolchain=msvc --extra-cflags=-DWIN32_LEAN_AND_MEAN". 

但是,还是有几个问题

1) 想要debug版的,所以还加上了 --enable-debug

2) 不想要 Warning消息,所以 configure 之后,编辑 config.mak , 把-W4 改成了 -w

CFLAGS= -nologo -DWIN32_LEAN_AND_MEAN   -Z7 -w

3)   cmdutils.c 卡在了 【AVOutputFormat *ofmt = NULL;】 , 查错误代码想了半天,才知道VC应该用下面的语法

struct AVOutputFormat *ofmt = NULL;

4) cmdutils.c 还卡在了【 av_log(NULL, level, "%sbuilt with %s ", indent, CC_IDENT);】

把参数一个一个排除,发觉问题出在 CC_IDENT .

最后把 config.h里的中文定义改成英文的才解决。 我也不想用中文版的,可是我不知道安装完之后,还能怎么改。

// #define CC_IDENT "用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.10.25019 版"
#define CC_IDENT "MSVC19.10.25019"

 5) SDL的编译

    a) 网站已经有mingw的开发库,下载就可以 http://www.libsdl.org/download-2.0.php

    b) 自己用source 在 mingw 编译。

          ../configure --host=x86_64-w64-mingw32

    c) make 会出error . 因为 SDL 的source 没有根据最新mingw做变更。

        需要注释掉 SDL2-2.0.5srccorewindowsSDL_xinput.h 的下面的代码

        typedef struct XXX XINPUT_GAMEPAD_EX   typedef struct  XINPUT_STATE_EX;

 6) x264的编译 , 屏蔽了几个模块。 这个好像是source级别的mingw限制。

     因为这个不会生成libx264.lib,废弃    ../configure --host=x86_64-w64-mingw32 --enable-shared --disable-thread --disable-avs

     a) ../configure --host=x86_64-w64-mingw32 --disable-thread  --disable-cli --enable-shared --extra-ldflags=-Wl,--output-def=libx264.def

     b) make 成功之后,拷贝 .def 文件到 /usr/local/lib

     c) 在 /usr/local/lib 执行 lib.exe /DEF:libx264.def

最后,ffplay 还是没有编译成功,太累了。

$ ../configure --toolchain=msvc   --extra-ldflags="-Libpath:/usr/local/lib" --extra-cflags='-DWIN32_LEAN_AND_MEAN -I/usr/include -I/usr/include/SDL2 -I/usr/local/include ' --enable-debug --enable-libx264 --enable-gpl --enable-shared --enable-static --enable-ffplay
原文地址:https://www.cnblogs.com/johnsonshu/p/7460941.html